<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="ca">
	<id>https://cacauet.org/wiki/index.php?action=history&amp;feed=atom&amp;title=PyQt4%3A_Marquesina_python</id>
	<title>PyQt4: Marquesina python - Historial de revisió</title>
	<link rel="self" type="application/atom+xml" href="https://cacauet.org/wiki/index.php?action=history&amp;feed=atom&amp;title=PyQt4%3A_Marquesina_python"/>
	<link rel="alternate" type="text/html" href="https://cacauet.org/wiki/index.php?title=PyQt4:_Marquesina_python&amp;action=history"/>
	<updated>2026-04-22T19:20:28Z</updated>
	<subtitle>Historial de revisió per a aquesta pàgina del wiki</subtitle>
	<generator>MediaWiki 1.34.0</generator>
	<entry>
		<id>https://cacauet.org/wiki/index.php?title=PyQt4:_Marquesina_python&amp;diff=2291&amp;oldid=prev</id>
		<title>Enric: Es crea la pàgina amb «Ale, aquí teniu més codi d'una marquesina o &quot;missatge rodant&quot;. Val a dir que podeu millorar l'aspecte de tot plegat...  &lt;syntaxhighlight lang=&quot;python&quot;&gt; #!/usr/bin/pytho…».</title>
		<link rel="alternate" type="text/html" href="https://cacauet.org/wiki/index.php?title=PyQt4:_Marquesina_python&amp;diff=2291&amp;oldid=prev"/>
		<updated>2014-01-31T16:18:54Z</updated>

		<summary type="html">&lt;p&gt;Es crea la pàgina amb «Ale, aquí teniu més codi d&amp;#039;una marquesina o &amp;quot;missatge rodant&amp;quot;. Val a dir que podeu millorar l&amp;#039;aspecte de tot plegat...  &amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt; #!/usr/bin/pytho…».&lt;/p&gt;
&lt;p&gt;&lt;b&gt;Pàgina nova&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Ale, aquí teniu més codi d'una marquesina o &amp;quot;missatge rodant&amp;quot;. Val a dir que podeu millorar l'aspecte de tot plegat...&lt;br /&gt;
&lt;br /&gt;
&amp;lt;syntaxhighlight lang=&amp;quot;python&amp;quot;&amp;gt;&lt;br /&gt;
#!/usr/bin/python&lt;br /&gt;
# -*- coding: utf-8 -*-&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
from PyQt4 import QtCore,QtGui&lt;br /&gt;
import sys&lt;br /&gt;
&lt;br /&gt;
class Pantalla(QtGui.QWidget):&lt;br /&gt;
    color = QtGui.QColor(255,255,255)&lt;br /&gt;
    frase = &amp;quot;&amp;quot;&lt;br /&gt;
    posx = 0&lt;br /&gt;
    posy = 0&lt;br /&gt;
    vel = -5&lt;br /&gt;
    &lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        super(Pantalla,self).__init__()&lt;br /&gt;
        &lt;br /&gt;
    def actualitza_pos(self):&lt;br /&gt;
        self.posx = self.posx + self.vel&lt;br /&gt;
        self.posy = self.height()/2&lt;br /&gt;
        # control limits&lt;br /&gt;
        longitud = len(self.frase)*10&lt;br /&gt;
        &lt;br /&gt;
        if self.posx &amp;lt;= -longitud:&lt;br /&gt;
            self.posx = self.width()&lt;br /&gt;
        elif self.posx &amp;gt;= self.width():&lt;br /&gt;
            self.posx = -longitud+1&lt;br /&gt;
        &lt;br /&gt;
    def paintEvent(self,e):&lt;br /&gt;
        qp = QtGui.QPainter()&lt;br /&gt;
        qp.begin(self)&lt;br /&gt;
&lt;br /&gt;
        self.actualitza_pos()&lt;br /&gt;
        &lt;br /&gt;
        qp.setBrush( self.color )&lt;br /&gt;
        qp.drawRect( 0, 0, self.width()-1, self.height()-1 )&lt;br /&gt;
        qp.drawText( self.posx, self.posy , self.frase )&lt;br /&gt;
        &lt;br /&gt;
        qp.end()&lt;br /&gt;
&lt;br /&gt;
class Marquesina(QtGui.QWidget):&lt;br /&gt;
    def __init__(self):&lt;br /&gt;
        super(Marquesina,self).__init__()&lt;br /&gt;
        self.initUI()&lt;br /&gt;
    &lt;br /&gt;
    def initUI(self):&lt;br /&gt;
        # elements&lt;br /&gt;
        self.set = QtGui.QPushButton(&amp;quot;Set&amp;quot;, self)&lt;br /&gt;
        self.textview = QtGui.QLineEdit(&amp;quot;posa text aqui...&amp;quot;, self)&lt;br /&gt;
        self.slider = QtGui.QSlider(QtCore.Qt.Vertical, self)&lt;br /&gt;
&lt;br /&gt;
        self.pantalla = Pantalla()&lt;br /&gt;
        &lt;br /&gt;
        # connexions SIGNALS i SLOTS&lt;br /&gt;
        self.set.clicked.connect( self.canvia_text )&lt;br /&gt;
        self.textview.returnPressed.connect( self.canvia_text )&lt;br /&gt;
        self.slider.valueChanged.connect( self.canvia_vel )&lt;br /&gt;
        &lt;br /&gt;
        self.grid = QtGui.QGridLayout()&lt;br /&gt;
        self.grid.addWidget(self.set,0,0)&lt;br /&gt;
        self.grid.addWidget(self.slider,1,0)&lt;br /&gt;
        self.grid.addWidget(self.textview,0,1)&lt;br /&gt;
        self.grid.addWidget(self.pantalla,1,1)&lt;br /&gt;
        &lt;br /&gt;
        self.setLayout( self.grid )&lt;br /&gt;
        &lt;br /&gt;
        self.setGeometry(150,150,700,600)&lt;br /&gt;
        self.show()&lt;br /&gt;
        &lt;br /&gt;
        self.timer = QtCore.QTimer()&lt;br /&gt;
        self.timer.timeout.connect( self.pantalla.repaint )&lt;br /&gt;
        self.timer.setInterval(50)&lt;br /&gt;
        self.timer.start()&lt;br /&gt;
        &lt;br /&gt;
        # veiem text des del principi dels temps&lt;br /&gt;
        self.canvia_text()&lt;br /&gt;
        self.setFocus()&lt;br /&gt;
&lt;br /&gt;
    def canvia_text(self):&lt;br /&gt;
        self.pantalla.frase = self.textview.text()&lt;br /&gt;
        self.setFocus()&lt;br /&gt;
    &lt;br /&gt;
    def canvia_vel(self):&lt;br /&gt;
        self.pantalla.vel = self.sender().value()&lt;br /&gt;
        self.setFocus()&lt;br /&gt;
&lt;br /&gt;
    def keyPressEvent(self,e):&lt;br /&gt;
        if e.key() == QtCore.Qt.Key_Left:&lt;br /&gt;
            self.pantalla.vel = -abs(self.pantalla.vel)&lt;br /&gt;
        elif e.key() == QtCore.Qt.Key_Right:&lt;br /&gt;
            self.pantalla.vel = abs(self.pantalla.vel)&lt;br /&gt;
        &lt;br /&gt;
&lt;br /&gt;
app = QtGui.QApplication([])&lt;br /&gt;
m = Marquesina()&lt;br /&gt;
sys.exit( app.exec_() )&lt;br /&gt;
&amp;lt;/syntaxhighlight&amp;gt;&lt;/div&gt;</summary>
		<author><name>Enric</name></author>
		
	</entry>
</feed>