示例#1
0
文件: dwgui.py 项目: ProgVal/Manygui
 def _register_class(self):
     if _verbose: log('Application._register_class:start',str(self))
     class WNDCLASS(structob.struct_object):
         oracle = structob.Oracle (
             'window class information',
             'Nllllllllll',
             ('style',
              'lpfnWndProc',
              'cls_extra',
              'wnd_extra',
              'hInst',
              'hIcon',
              'hCursor',
              'hbrBackground',
              'menu_name',
              'lpzClassName',
              )
             )
     self._class_name = windll.cstring("dw.manygui.PythonWindow")
     self.__wndproc = gencb.generated_callback('llll',self._wndproc)
     # register a window class for our windows.
     wc = WNDCLASS()
     wc.hbrBackground = COLOR_BTNFACE + 1
     wc.hCursor = user32.LoadCursor(0, IDC_ARROW)
     wc.hIcon = user32.LoadIcon(0, IDI_APPLICATION)
     wc.lpzClassName = self._class_name.address()
     wc.lpfnWndProc = self.__wndproc.address
     wc.hInst = kernel32.GetModuleHandle(0)
     self._wc = wc
     user32.UnregisterClass(wc.lpzClassName,0)
     self.__class__._wndclass = user32.RegisterClass(wc)
     assert self.__class__._wndclass, "RegisterClass --> %d=%s ie\n%s" % (GetLastError(), hex(GetLastError()), _lastErrorMessage())
     if _verbose: log('Application._register_class:end',str(self))
示例#2
0
文件: dwgui.py 项目: ProgVal/Manygui
 def widgetSetUp(self):
     if _verbose: log('widgetSetup',str(self))
     self.proxy.container.wrapper.widget_map[self.widget] = self
     user32.SendMessage(self.widget,
                          WM_SETFONT,
                          self._hfont,
                          0)
     self.setVisible(1)
示例#3
0
 def _fn2handle(self,fn):
     if self.kind=='bitmap':
         try:
             self._handle = LoadImage(0,c_buffer(fn),
                 IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE)
         except:
             log(WinError())
             raise
示例#4
0
 def callback(i=i,*args,**kws): # Store the index
     for j in range(num):
         if j!=i:
             fms[j].visible = 0
             log('Frame %s hidden' % j)
         else:
             fms[j].visible = 1
             log('Frame %s shown' % j)
示例#5
0
def say_hello(source, event):
    log("Hello, world!")
    global newbtn
    if newbtn is None:
        newbtn = Button(opt, y = g_y)
        newbtn.text = TextModel('new')
        win.add(newbtn)
    else:
        newbtn.text.append('x')
示例#6
0
文件: dwgui.py 项目: ProgVal/Manygui
 def getGeometry(self):
     if not self.widget: return 0,0,0,0
     r = t_rect()
     user32.GetWindowRect(self.widget,r)
     l,t,r,b = r.rect
     w = r-l-self._extraWidth
     h = b-t-self._extraHeight
     if _verbose: log(str(self),'getGeometry WindowWrapper:', l,t,w,h)
     return l,t,w,h
示例#7
0
文件: dwgui.py 项目: ProgVal/Manygui
 def _fn2handle(self,fn):
     if self.kind=='bitmap':
         try:
             self._handle = user32.LoadImage(0,windll.cstring(fn),
                 IMAGE_BITMAP,0,0,LR_DEFAULTSIZE|LR_LOADFROMFILE)
         except:
             logTraceback(None)
             from manygui.backends.dwgui import _lastErrorMessage 
             log(_lastErrorMessage())
示例#8
0
def say_hello(event):
    log("Hello, world!")
    global newbtn
    if newbtn is None:
        newbtn = Button(opt, y = g_y)
        newbtn.installTextModel(TextModel('new'))
        link(newbtn.text, model_event)
        win.add(newbtn)
    else:
        newbtn.text.append('x')
示例#9
0
文件: dwgui.py 项目: ProgVal/Manygui
 def draw(self,*arg,**kw):
     if _verbose: log('Image.draw',self.widget,self._image)
     if not self.widget or not self._image: return
     dc = user32.GetDC(self.widget)
     memdc = gdi32.CreateCompatibleDC(dc)
     if _verbose: log('Image.draw dc, memdc',dc,memdc)
     old = gdi32.SelectObject(memdc,self._image.handle())
     gdi32.BitBlt(dc,0,0,self.proxy.width,self.proxy.height,memdc,0,0,0x00CC0020)
     gdi32.SelectObject(memdc,old)
     gdi32.DeleteDC(memdc)
示例#10
0
文件: dwgui.py 项目: ProgVal/Manygui
 def __init__(self,**kwds):
     global _app
     if not _app:
         if _verbose: log('Application.__init__:start',str(self))
         AbstractApplication.__init__(self,**kwds)
         if not self._wndclass: self._register_class()
         WindowWrapper._wndclass = self._wndclass
         FrameWrapper._wndclass = self._wndclass
         _app = self
         if _verbose: log('Application.__init__:end',self)
示例#11
0
文件: dwgui.py 项目: ProgVal/Manygui
 def setGeometry(self,x,y,width,height):
     if not self.widget: return
     if _verbose: log('WindowWrapper: setGeometry',str(self),self.widget,x,y,width,height,self._extraWidth,self._extraHeight)
     # take account for title bar and borders
     user32.SetWindowPos(self.widget,
                           0,
                           x, y,
                           width + self._extraWidth,
                           height + self._extraHeight,
                           SWP_NOACTIVATE | SWP_NOZORDER)
     user32.UpdateWindow(self.widget)
示例#12
0
def say_hello(source, event):
    log("Hello, world!")
    global newbtn
    if newbtn is None:
        newbtn = CheckBox(opt, y = g_y)
        newbtn.on = BooleanModel()
        link(newbtn, printit1)
        link(newbtn.on, printit2)
        win.add(newbtn)
    else:
        newbtn.on = not newbtn.on
示例#13
0
文件: dwgui.py 项目: ProgVal/Manygui
 def handle(self):
     if not self._handle:
         if self.inline:
             import zlib, base64, tempfile, os
             fn = tempfile.mktemp(self.suffix)
             if _verbose: log('resource:','fn',fn,'kind',self.kind)
             open(fn,'wb').write(zlib.decompress(base64.decodestring(self.text)))
             try:
                 self._fn2handle(fn)
             finally:
                 os.remove(fn)
         else:
             self._fn2handle(self.text)
     if _verbose: log('resource:','-->',self._handle)
     return self._handle
示例#14
0
文件: dwgui.py 项目: ProgVal/Manygui
    def _WM_SIZE(self, hwnd, msg, wParam, lParam):
        w, h = lParam & 0xFFFF, lParam >> 16
        if _verbose: log('WindowWrapper: _WM_SIZE _width,_height,w,h=',self._width,self._height,w,h,)
        if self._width==0 and self._height==0:
            # This will be the case when the widget is first
            # created. We need to ensure the contents get
            # reasonable geometries before we start sliding
            # them around, so ignore the initial resize.
            dw=0
            dh=0
        else:
            dw = w - self._width
            dh = h - self._height
        if _verbose: log('dw,dh=',dw,dh)

        self._width = w
        self._height = h
        if (dw,dh)!=(0,0): self.proxy.resized(dw,dh)
        return 0
示例#15
0
文件: dwgui.py 项目: ProgVal/Manygui
    def getGeometry(self):
        if not self.widget: return 0,0,0,0
        r = t_rect()
        user32.GetWindowRect(self.widget,r)
        l,t,r,b = r.rect
        w = r-l
        h = b-t

        if _verbose: log(str(self),'getGeometry',l,t,w,h)
        try:
            p = t_point()
            p.point = l,t
            user32.ScreenToClient(self.proxy.container.wrapper.widget,p)
            l,t = p.point
            if _verbose: log('   -->', l,t,w,h)
        except AttributeError:
            pass
        except:
            logTraceback(None)
        return l,t,w,h
示例#16
0
文件: dwgui.py 项目: ProgVal/Manygui
 def _wndproc(self, hwnd, msg, wParam, lParam):
     if _verbose: log("%s._wndproc called with %s,%s,%s,%s"%(self.__class__.__name__,hex(hwnd),hex(msg),hex(wParam),hex(lParam)))
     try:
         window = self.widget_map[hwnd]
     except:
         if _verbose: log("\tNO WINDOW TO DISPATCH???")
         return user32.DefWindowProc(hwnd, msg, wParam, lParam)
     try:
         _dispatch = self._dispatch.get(msg,_dispatch_DEFAULT)
         x = _dispatch(window,hwnd,msg,wParam,lParam)
     except:
         logTraceback(None,'_wndproc.1')
     if _verbose: log("\tdispatch %s to %s %s\n" % (_dispatch.__name__[9:],window.__class__.__name__,window),"\t ==>",x)
     return x
示例#17
0
文件: dwgui.py 项目: ProgVal/Manygui
 def internalRun(self):
     if _verbose: log('internalRun:Begin',str(self))
     class MSG(structob.struct_object):
         oracle = structob.Oracle (
             'windows message',
             'Nlllllll',
             ('hwnd',
              'message',
              'wParam',
              'lParam',
              'time',
              'x',
              'y')
             )
     msg = MSG()
     while user32.GetMessage(msg, 0, 0, 0):
         try:
             if _verbose: log('internalRun: loopstart',msg)
             user32.TranslateMessage(msg)
             user32.DispatchMessage(msg)
             if _verbose: log('internalRun: loopend')
         except:
             if _verbose: logTraceback(None)
     if _verbose: log('internalRun: finish')
示例#18
0
文件: dwgui.py 项目: ProgVal/Manygui
 def _WM_COMMAND(self, hwnd, msg, wParam, lParam):
     if _verbose: log("ContainerMixin _WM_COMMAND called for %s"%self)
     # lParam: handle of control (or NULL, if not from a control)
     # HIWORD(wParam): notification code
     # LOWORD(wParam): id of menu item, control, or accelerator
     try:
         app = application()
         child_window = self.widget_map[lParam]
     except KeyError:
         if _verbose: log("NO SUCH CHILD WINDOW %s"%lParam)
         # we receive (when running test_textfield.py)
         # EN_CHANGE (0x300) and EN_UPDATE (0x400) notifications
         # here even before the call to CreateWindow returns.
         return -1
     except:
         logTraceback(None)
     if _verbose: log("Dispatching to child %s"%child_window)
     return child_window._WM_COMMAND(hwnd, msg, wParam, lParam)
示例#19
0
def report(event):
    log("Check box set to", box.on)
示例#20
0
文件: dwgui.py 项目: ProgVal/Manygui
 def _WM_COMMAND(self, hwnd, msg, wParam, lParam):
     if _verbose: log('WindowWrapper: _WM_COMMAND',str(self),hwnd,msg,wParam,lParam)
     return ContainerMixin._WM_COMMAND(self, hwnd, msg, wParam, lParam)
示例#21
0
文件: dwgui.py 项目: ProgVal/Manygui
 def setText(self,text):
     if not self.widget: return
     if _verbose: log("%s.SetWindowText('%s'(%s)) hwnd=%s(%s) self=%s" % (self.__class__.__name__,text,type(text),self.widget,type(self.widget),self))
     user32.SetWindowTextA(self.widget,windll.cstring(_to_native(text)))
示例#22
0
def report(event):
    log("Radio button clicked")
    btn.on = not btn.on
示例#23
0
文件: dwgui.py 项目: ProgVal/Manygui
 def internalRemove(self):
     if not self._windows:
         if _verbose: log('PostQuitMessage(0)')
         user32.PostQuitMessage(0)
         global _app
         _app = None
示例#24
0
def print_contents(event):
    global tf
    log('Enter was pressed. Field contents:', tf.text)
示例#25
0
文件: dwgui.py 项目: ProgVal/Manygui
 def _WM_PAINT(self, hwnd, msg, wParam, lParam):
     if not self.widget: return -1
     if _verbose: log('Image _WM_PAINT self.__dict__',self.__dict__)
     r = ComponentWrapper._WM_PAINT(self, hwnd, msg, wParam, lParam)
     self.draw()
     return r
示例#26
0
文件: dwgui.py 项目: ProgVal/Manygui
 def setGeometry(self,x,y,width,height):
     if self.widget:
         if _verbose: log(str(self),'setGeometry', x,y,width,height)
         user32.SetWindowPos(self.widget, 0, x, y, width, height, SWP_NOACTIVATE | SWP_NOZORDER)
         user32.UpdateWindow(self.widget)
示例#27
0
def printit(event):
    log('printit:',newbtn.text)
示例#28
0
文件: dwgui.py 项目: ProgVal/Manygui
 def widgetSetUp(self):
     if _verbose: log('Windowwrapper widgetSetup',str(self),'application()',application(),'isRunning()',application().isRunning(),'widget',getattr(self,'widget',None))
     application().widget_map[self.widget] = self
     user32.SendMessage(self.widget, WM_SETFONT, self._hfont, 0)
示例#29
0
文件: dwgui.py 项目: ProgVal/Manygui
 def internalProd(self):
     if _verbose: log('internalProd',str(self))
     self.proxy.push(blocked=['container'])
示例#30
0
文件: dwgui.py 项目: ProgVal/Manygui
 def setVisible(self,visible):
     if self.widget:
         if _verbose: log(str(self),'setVisible', visible, self.widget)
         user32.ShowWindow(self.widget, visible and SW_SHOWNORMAL or SW_HIDE)