[Pychord-commits] r47 - in trunk: pgui pychord2
danilo at garage.maemo.org
danilo at garage.maemo.org
Sun Mar 9 15:13:53 EET 2008
Author: danilo
Date: 2008-03-09 15:13:52 +0200 (Sun, 09 Mar 2008)
New Revision: 47
Modified:
trunk/pgui/button.py
trunk/pgui/list.py
trunk/pgui/locale.py
trunk/pgui/pguiobject.py
trunk/pychord2/main_window.py
Log:
- List widget added
- A new type of slot was created: whilePressedSlot, and it is executed while the mouse is clicking a button
Modified: trunk/pgui/button.py
===================================================================
--- trunk/pgui/button.py 2008-03-06 02:53:59 UTC (rev 46)
+++ trunk/pgui/button.py 2008-03-09 13:13:52 UTC (rev 47)
@@ -83,4 +83,5 @@
size = img.get_size()
button.__init__(self, father, position, size, img)
+
Modified: trunk/pgui/list.py
===================================================================
--- trunk/pgui/list.py 2008-03-06 02:53:59 UTC (rev 46)
+++ trunk/pgui/list.py 2008-03-09 13:13:52 UTC (rev 47)
@@ -19,6 +19,9 @@
self.bsize = bsize
self.position = position
self.ptsize = ptsize
+
+ #Autoscroll
+ self.autoScroll(0)
container.__init__(self, father,[],position,[width, height])
# label
@@ -33,9 +36,40 @@
if self.clicked:
pos = pygame.mouse.get_rel()
self.move(pos[1])
+ elif self.autoScrollEnabled:
+ self.speedAux += 1
+
+ if self.speedAux == 1:
+ self.move(-2)
+
+ elif self.speedAux > pguiListMaximumSpeed - self.autoScrollSpeed:
+ self.speedAux = 0
+
+ container.update(self)
+
def move(self,pos):
for i in self.objects:
- i.move([0,pos])
\ No newline at end of file
+ i.move([0,pos])
+
+ def autoScroll(self, speed):
+ if speed > pguiListMaximumSpeed:
+ speed = pguiListMaximumSpeed
+
+ if speed <= 0:
+ self.speedAux = 0
+ self.autoScrollEnabled = False
+ self.autoScrollSpeed = 0
+ else:
+ self.autoScrollEnabled = True
+ self.autoScrollSpeed = speed
+
+ print speed
+
+ def increaseSpeed(self):
+ self.autoScroll(self.autoScrollSpeed + 1)
+
+ def decreaseSpeed(self):
+ self.autoScroll(self.autoScrollSpeed - 1)
\ No newline at end of file
Modified: trunk/pgui/locale.py
===================================================================
--- trunk/pgui/locale.py 2008-03-06 02:53:59 UTC (rev 46)
+++ trunk/pgui/locale.py 2008-03-09 13:13:52 UTC (rev 47)
@@ -10,8 +10,15 @@
pguiAlignCenter = 1 # Default Align position
pguiAlignLeft = 2 # AlignLeft position
+#SlotsTypeFlags
+pguiOnClickSlot = 1
+pguiWhilePressedSlot = 2
+#List Widget
+pguiListMaximumSpeed = 40
+
+
#THEME OPTIONS
pguiDefFontSize = 40 # Default FontSize
Modified: trunk/pgui/pguiobject.py
===================================================================
--- trunk/pgui/pguiobject.py 2008-03-06 02:53:59 UTC (rev 46)
+++ trunk/pgui/pguiobject.py 2008-03-09 13:13:52 UTC (rev 47)
@@ -35,7 +35,7 @@
self.position = position
- self.onClickSlots = []
+ self.Slots = []
def setBackground(self, bg, flag = pguiColor):
@@ -89,8 +89,18 @@
def onMouseOff(self):
pass
+ def whilePressed(self):
+
+ for type,functionName,vars in self.Slots:
+ if type == pguiWhilePressedSlot:
+ if vars != None:
+ functionName(vars)
+ else:
+ functionName()
+
def onClick(self):
+ print "onClick",self
self.mouseOn = True
self.clicked = True
self.onMouseOn()
@@ -105,18 +115,26 @@
self.onMouseOff()
def update(self):
+
+ if self.mouseOn and self.clicked:
+ self.whilePressed()
+
pass
def click(self):
- for functionName,vars in self.onClickSlots:
- if vars != None:
- functionName(vars)
- else:
- functionName()
+ for type,functionName,vars in self.Slots:
+ if type == pguiOnClickSlot:
+ if vars != None:
+ functionName(vars)
+ else:
+ functionName()
def registerClickSlot(self, functionName, vars = None):
- self.onClickSlots.append([functionName,vars])
+ self.Slots.append([pguiOnClickSlot,functionName,vars])
+
+ def registerPressedSlot(self, functionName, vars = None):
+ self.Slots.append([pguiWhilePressedSlot,functionName,vars])
def setPositionByRelative(self, position = [0,0]):
self.rel_pos = position # Defining relative position
Modified: trunk/pychord2/main_window.py
===================================================================
--- trunk/pychord2/main_window.py 2008-03-06 02:53:59 UTC (rev 46)
+++ trunk/pychord2/main_window.py 2008-03-09 13:13:52 UTC (rev 47)
@@ -46,7 +46,26 @@
lst = list(self, [0,0],["Ola mundo, bla bla bla", "Ola mundo, bla bla bla",
"Ola mundo, bla bla bla","Ola mundo, bla bla bla","Ola mundo, bla bla bla",
+ "Ola mundo, bla bla bla","Ola mundo, bla bla bla","Ola mundo, bla bla bla",
+ "Ola mundo, bla bla bla", "Ola mundo, bla bla bla",
+ "Ola mundo, bla bla bla","Ola mundo, bla bla bla","Ola mundo, bla bla bla",
+ "Ola mundo, bla bla bla","Ola mundo, bla bla bla","Ola mundo, bla bla bla",
+ "Ola mundo, bla bla bla", "Ola mundo, bla bla bla",
+ "Ola mundo, bla bla bla","Ola mundo, bla bla bla","Ola mundo, bla bla bla",
"Ola mundo, bla bla bla","Ola mundo, bla bla bla","Ola mundo, bla bla bla"])
- lst.setBackground((50,50,50))
+ lst.setBackground((10,10,10))
+ lst.autoScroll(2)
self.addElement(lst)
+
+ btFF = Ibutton(self,[730,400],"ff.png")
+ btFF.registerPressedSlot(lst.increaseSpeed)
+ self.addElement(btFF)
+
+ btST = Ibutton(self,[730,350],"stop.png")
+ btST.registerClickSlot(lst.autoScroll,0)
+ self.addElement(btST)
+
+ btRR = Ibutton(self,[730,300],"rr.png")
+ btRR.registerPressedSlot(lst.decreaseSpeed)
+ self.addElement(btRR)
\ No newline at end of file
More information about the Pychord-commits
mailing list