Explorar el Código

*** empty log message ***

Mark Mine hace 24 años
padre
commit
277ecc063e
Se han modificado 2 ficheros con 41 adiciones y 5 borrados
  1. 7 5
      direct/src/tkwidgets/Floater.py
  2. 34 0
      direct/src/tkwidgets/Slider.py

+ 7 - 5
direct/src/tkwidgets/Floater.py

@@ -48,11 +48,11 @@ class FloaterWidget(Pmw.MegaWidget):
         INITOPT = Pmw.INITOPT
         optiondefs = (
             # Appearance
-            ('width',           FLOATER_WIDTH,  INITOPT),
-            ('height',          FLOATER_HEIGHT, INITOPT),
-            ('relief',          SUNKEN,         self.setRelief),
-            ('borderwidth',     2,              self.setBorderwidth),
-            ('background',      'white',        self.setBackground),
+            ('width',           FLOATER_WIDTH,      INITOPT),
+            ('height',          FLOATER_HEIGHT,     INITOPT),
+            ('relief',          RAISED,             self.setRelief),
+            ('borderwidth',     2,                  self.setBorderwidth),
+            ('background',      'SystemButtonFace', self.setBackground),
             # Behavior
             # Initial value of floater, use self.set to change value
             ('value',           0.0,            INITOPT),
@@ -141,6 +141,7 @@ class FloaterWidget(Pmw.MegaWidget):
     def mouseDown(self,event):
         """ Begin mouse interaction """
         # Exectute user redefinable callback function (if any)
+        self['relief'] = SUNKEN
         if self['preCallback']:
             apply(self['preCallback'], self['callbackData'])
         self.velocitySF = 0.0
@@ -181,6 +182,7 @@ class FloaterWidget(Pmw.MegaWidget):
         # Execute user redefinable callback function (if any)
         if self['postCallback']:
             apply(self['postCallback'], self['callbackData'])
+        self['relief'] = RAISED
 
     def setNumDigits(self):
         """

+ 34 - 0
direct/src/tkwidgets/Slider.py

@@ -268,3 +268,37 @@ if __name__ == '__main__':
     d2.pack(expand = 1, fill = X)
     d3.pack(expand = 1, fill = X)
     d4.pack(expand = 1, fill = X)
+
+
+
+class PopupSliderWidget(Pmw.MegaToplevel):
+    def __init__(self, parent = None, **kw):
+        optiondefs = (
+            ('width',                    150,            None),
+            ('height',                   30,             None),
+            ('xoffset',                  0,              None), # pixels
+            ('yoffset',                  1,              None), # pixels
+            )
+        self.defineoptions(kw, optiondefs)
+        Pmw.MegaToplevel.__init__(self, parent)
+        self.withdraw()
+        self.overrideredirect(1)
+        self.interior()['relief'] = RAISED
+        self.interior()['borderwidth'] = 3
+        self.b = Button(self.interior(), text = 'hello')
+        self.b['command'] = self.withdraw
+        self.b.pack()
+        self.initialiseoptions(PopupSliderWidget)
+    def showPopup(self, widget):
+        x = widget.winfo_rootx() + widget.winfo_width() - self['width']
+        y = widget.winfo_rooty() + widget.winfo_height()
+        Pmw.setgeometryanddeiconify(self, '%dx%d+%d+%d' %
+                                    (self['width'], self['height'],x,y))
+"""
+pw = PopupSliderWidget()
+tl = Toplevel()
+b = Button(tl, text = 'hello')
+b.pack(expand = 1, fill = X)
+b.bind('<ButtonPress-1>', lambda event, s = b: pw.showPopup(b))
+#b.bind('<ButtonRelease-1>', lambda event: pw.withdraw())
+"""