All pastes #1530154 Raw Edit

Mine

public python v1 · immutable
#1530154 ·published 2009-08-15 03:16 UTC
rendered paste body
#!/usr/bin/env pythonclass box:    classname = "widget"    type = "widget"    border = 4    parent = None    child = None    debug_events = False    _evt_name = {}    _connect_id = 0    _connect_dict = {}    _add_pending = []    def __init__(self,*args,**kw):        self.create_wclass()        self._register_wclass()        self.init(*args,**kw)        self._post_init()        def init(self,*args,**kw):                raise NotImplementedError, "This is a virtual widget, can't initalize itself"        def _post_init(self):        s = style.Style(self)        for i in self.style:            s.add(i)        self.style = s        def create_wclass(self):        raise NotImplementedError, "To create a widget, you need to create a wclass method"    def _register_wclass(self):        global WM_SOCKET        wproc = {}        #creating event table, to translating when debug        for j in [i for i in dir(win32con) if i.startswith("WM_")]:            self._evt_name[getattr(win32con,j)] = j            wproc[getattr(win32con,j)] = self._event_dispacher        wproc[WM_SOCKET] = self._event_dispacher        self.wc.lpfnWndProc = self._event_dispacher        self.wclass = win32gui.RegisterClass(self.wc)        del self.wc        def _event_dispacher(self,hwnd,Message,lParam,hParam):        flag = False                if Message == WM_SIZE:            self._on_resize()                    if Message == WM_SHOWWINDOW and lParam == 1:            try:                self.add_pennding()            except:                pass                    if self.debug_events:            if Message in self._evt_name:                evt_name = self._evt_name[Message]            else: evt_name = Message            print "evt: ", evt_name, lParam, hParam        if Message in self._connect_dict:            for i in self._connect_dict[Message]:                flag = i[1](hwnd,lParam,hParam,*i[2])                        if not flag:            return win32gui.DefWindowProc(hwnd,Message,lParam,hParam)        else: return flag;        def connect(self, event, callback, *args):        if event in self._connect_dict:            self._connect_dict[event].append([self._connect_id, callback,args])        else:            self._connect_dict[event] = [[self._connect_id, callback,args]]        r = self._connect_id        self._connect_id += 1        return r        def disconnect(self,id):        for i in self._connect_dict:            for j in i:                if id == j[0]:                    del i[j]                    return        def fit_to_parent(self):        if self.parent:            psize = self.parent.get_client_size()            ssize = list(self.get_size())            if (style.sizer, style.sizer.FIT_TO_PARENT) in self.style._style:                x = self.parent.border                y = self.parent.border                ssize = (psize[0] - self.parent.border * 2, psize[1] - self.parent.border * 2)            else:                #Vertical Resizing                if (style.sizer, style.sizer.VALIGN_MIDDLE) in self.style._style:                    y = (psize[1] - ssize[1]) / 2                elif (style.sizer, style.sizer.VALIGN_TOP) in self.style._style:                    y = self.parent.border                elif (style.sizer, style.sizer.VALIGN_BOTTOM) in self.style._style:                    y = psize[1] - self.parent.border - ssize[1]                elif (style.sizer, style.sizer.VEXPAND) in self.style._style:                    y = self.parent.border                    ssize[1] = psize[1] - self.parent.border * 2                                    #Horizontal Resizing                if (style.sizer, style.sizer.HALIGN_CENTER) in self.style._style:                    x = (psize[0] - ssize[0]) / 2                elif (style.sizer, style.sizer.HALIGN_LEFT) in self.style._style:                    x = self.parent.border                elif (style.sizer, style.sizer.HALIGN_RIGHT) in self.style._style:                    x = psize[0] - self.parent.border - ssize[0]                elif (style.sizer, style.sizer.HEXPAND) in self.style._style:                    x = self.parent.border                    ssize[0] = psize[0] - self.parent.border * 2                                self.move_resize((x,y),ssize)        def fit_to_child(self):        if self.child:            v, h = self.child.get_size()            self.child.move((self.border,self.border))            self.resize(v + self.border, h + self.border)        def _on_resize(self):        if self.child:            self.child.fit_to_parent()        if self.parent:            self.parent.fit_to_child()        def add_pennding(self):        self._add_pending = list(set(self._add_pending))        try:            for i in self._add_pending:                self.add(i,True)        finally:            self._add_pending = []                def add(self,widget,force = False):        if not win32gui.IsWindowVisible(self.hwnd) and not force:            self._add_pending.append(widget)            return        if self.child:            raise OverflowError, "no  possvel adicionar mais de um widget a um widget."                    if widget.type == "widget":            win32gui.SetWindowLong(widget.hwnd, GWL_STYLE, WS_CHILD)            win32gui.SetParent(widget.hwnd,self.hwnd)            self.child = widget            widget.parent = self            widget.fit_to_parent()            def get_client_rect(self):        return win32gui.GetClientRect(self.hwnd)            def get_rect(self):        return win32gui.GetWindowRect(self.hwnd)        def get_size(self):        r = self.get_rect()        return (r[2]-r[0],r[3]-r[1])        def get_client_size(self):        return self.get_client_rect()[2:]            def get_pos(self):        return self.get_rect()[:2]        def move(self,xy,repaint = True):        args = list(xy) + list(self.get_size()) + [repaint]        win32gui.MoveWindow(self.hwnd,*args)        def resize(self,wh,repaint = True):        args = list(self.get_pos()) +  list(wh) + [repaint]        win32gui.MoveWindow(self.hwnd,*args)        def move_resize(self,xy,wh,repaint = True):        args = list(xy) + list(wh) + [repaint]        win32gui.MoveWindow(self.hwnd,*args)    #def move_resize(self,rect,repaint = True):    #    self.move_resize(self,rect[:2],(rect[2]-rect[0],rect[3]-rect[1]),repaint);            def show(self,show=True):        win32gui.ShowWindow(self.hwnd,show)        def show_all(self):        self.show()        if self.child:            self.child.show_all()        def set_font(self,font):        win32gui.SendMessage(self.hwnd,WM_SETFONT,font.handle)            def close(self):        win32gui.DestroyWindow(self.hwnd)            #!/usr/bin/env python# -*- encoding: utf-8 -*-from widget_wrapper import *class Button(widget_wrapper):    style = [style.sizer.HEXPAND, style.sizer.VEXPAND]    WidgetName = "BUTTON"#!/usr/bin/env pythonfrom widget_wrapper import *import ctypesclass ComboBox(widget_wrapper):        style = [style.window.VSCROLL,             style.listbox.DROPDOWN,	     style.listbox.NOINTEGRALHEIGHT,             style.sizer.FIT_PARENT,             style.sizer.HEXPAND, style.sizer.VALIGN_BOTTOM,             style.edit.TEXT_ALIGN_CENTER]    WidgetName = "ComboBox"    DefaultSize = [300, 300]    dropdown_list_size = 6        def __getitem__(self,index):        d = ctypes.c_buffer(256)        win32gui.SendMessage(self.hwnd,CB_GETLBTEXT,index,d)        return d.value            def __setitem__(self,index,data):        win32gui.SendMessage(self.hwnd,CB_SETITEMDATA,index,string)        def select(self,index):        win32gui.SendMessage(self.hwnd, CB_SETCURSEL, index, 0 )            def move_resize(self,xy,wh,repaint = True):        tl = win32gui.GetTextExtentPoint32(win32gui.GetWindowDC(self.hwnd),"I gonna kill my lady")[1] + 1        widget_wrapper.move_resize(self, xy, (wh[0], wh[1]+tl*self.dropdown_list_size), repaint)            def remove(self,index):        win32gui.SendMessage(self.hwnd,CB_DELETESTRING,index,0)                    def clear(self):        win32gui.SendMessage(self.hwnd,CB_RESETCONTENT,0,0)            def append(self,data):        win32gui.SendMessage(self.hwnd,CB_ADDSTRING,0,data)                def count(self):    #    return len(self)                #def __len__(self):        return win32gui.SendMessage(self.hwnd,CB_GETCOUNT,0,0);                    def insert(self,string):        win32gui.SendMessage(self.hwnd,CB_INSERTSTRING,0,string)        #!/usr/bin/env python# -*- encoding: utf-8 -*-from widget_wrapper import *class Edit(widget_wrapper):    style = [style.edit.AUTO_HSCROLL, style.window.BORDER, style.window.CLIENT_EDGE,             style.sizer.FIT_PARENT, style.sizer.HALIGN_LEFT, style.sizer.VALIGN_TOP, style.edit.TEXT_ALIGN_CENTER]    WidgetName = "EDIT"    DefaultSize = [300, -1]    def init(self):        if self.DefaultSize[1] == -1:            self.DefaultSize[1] = win32gui.GetTextExtentPoint32(win32gui.GetWindowDC(self.hwnd),win32gui.GetWindowText(self.hwnd))[1] + 2                self.resize(self.DefaultSize)        print win32gui.GetTextExtentPoint32(win32gui.GetWindowDC(self.hwnd),win32gui.GetWindowText(self.hwnd))#!/usr/bin/env pythonimport win32guiimport win32conimport win32apiimport exceptionsimport win32processfrom win32con import *import ctypesuser32 = ctypes.windll.user32class Font:    def __init__(self,Default=True):        self.handle = win32gui.GetStockObject(ANSI_VAR_FONT)#!/usr/bin/env pythonfrom widget_wrapper import *import ctypesclass Label(widget_wrapper):    #!/usr/bin/env python# -*- encoding: utf-8 -*-    sel = False;    style = [style.sizer.FIT_PARENT, style.sizer.HALIGN_CENTER, style.sizer.VALIGN_MIDDLE]    WidgetName = "Static"    DefaultSize = [-1, -1]    _focus_handle = []    #debug_events = True    def init(self):        win32gui.SendMessage(self.hwnd,EM_SETBKGNDCOLOR,0,win32gui.GetSysColorBrush(win32con.COLOR_3DFACE))        if self.DefaultSize[1] == -1:            self.DefaultSize[1] = win32gui.GetTextExtentPoint32(win32gui.GetWindowDC(self.hwnd),win32gui.GetWindowText(self.hwnd))[1] + 2                self.resize(self.DefaultSize)    #!/usr/bin/env pythonimport win32conimport win32guiclass window:    BORDER =  "WS_BORDER"    CLIENT_EDGE =  "WS_EX_CLIENTEDGE"    STATIC_EDGE =  "WS_EX_STATIC_EDGE"    TOOLWINDOW =  "WS_EX_TOOLWINDOW"    OVERLAPPEDWINDOW =  "WS_OVERLAPPEDWINDOW"    TABSTOP =  "WS_TABSTOP"    VSCROLL =  "WS_VSCROLL"    HSCROLL =  "WS_HSCROLL"    TOPMOST =  "WS_EX_TOPMOST"   class edit:    MULTILINE =  "ES_MULTILINE"    NUMBER =  "ES_NUMBER"    READONLY =  "ES_READONLY"    UPPERCASE =  "ES_UPPERCASE"    PASSWORD =  "ES_PASSWORD"    LOWERCASE =  "ES_LOWERCASE"    AUTO_HSCROLL =  "ES_AUTOHSCROLL"    AUTO_VSCROLL =  "ES_AUTOVSCROLL"    TEXT_ALIGN_CENTER = "ES_CENTER"    TEXT_ALIGN_LEFT =  "ES_LEFT"    TEXT_ALIGN_RIGHT =  "ES_RIGHT"    WANT_RETURN =  "ES_WANTRETURN"        class listbox:    COMBOBOX = "LBS_COMBOBOX"    DROPDOWN = "CBS_DROPDOWN"    DROPDOWNLIST = "CBS_DROPDOWNLIST"    SIMPLE = "CBS_SIMPLE"    HASSTRING = "CBS_HASSTRING"    NOINTEGRALHEIGHT = "CBS_NOINTEGRALHEIGHT"    OWNERDRAWVARIABLE = "CBS_OWNERDRAWVARIABLE"class static:    ETCHEDFRAME = "SS_ETCHEDFRAME"    ETCHEDHORZ =  "SS_ETCHEDHORZ"    ETCHEDVERT = "SS_ETCHEDVERT"    GRAYFRAME = "SS_GRAYFRAME"    GRAYRECT = "SS_GRAYRECT"    ICON = "SS_ICON"    LEFT = "SS_LEFT"    LEFTNOWORDWRAP = "SS_LEFTNOWORDWRAP"    NOPREFIX  = "SS_NOPREFIX"    NOTIFY = "SS_NOTIFY"    OWNERDRAW = "SS_OWNERDRAW"    PATHELLIPSIS = "SS_PATHELLIPSIS"    REALSIZEIMAGE = "SS_REALSIZEIMAGE"    RIGHT = "SS_RIGHT"    RIGHTJUST = "SS_RIGHTJUST"    SIMPLE = "SS_SIMPLE"    SUNKEN = "SS_SUNKEN"    TYPEMASK = "SS_TYPEMASK"    USERITEM = "SS_USERITEM"    WHITEFRAME = "SS_WHITEFRAME"    WHITERECT = "SS_WHITERECT"    WORDELLIPSIS = "SS_WORDELLIPSIS"    BITMAP = "SS_BITMAP"    BLACKFRAME =  "SS_BLACKFRAME"    BLACKRECT  =  "SS_BLACKRECT"    CENTER   = "SS_CENTER"    CENTERIMAGE =   "SS_CENTERIMAGE"    ELLIPSISMASK =  "SS_ELLIPSISMASK"    ENDELLIPSIS  =  "SS_ENDELLIPSIS"    ENHMETAFILE  =  "SS_ENHMETAFILE"    class sizer:    VEXPAND =  1    HEXPAND =  2    HALIGN_LEFT =  4    VALIGN_TOP =  8    HALIGN_CENTER =  16    VALIGN_MIDDLE =  32    VALIGN_BOTTOM =  64    FIT_TO_PARENT =  128    FIT_PARENT =  256    HALIGN_RIGHT =  512class Style:    _style = []    def __init__(self,parent):        self.parent = parent            def add(self,cls,style=None):        if type(cls) == str:            #finding class            for i in (window,edit,listbox,static):                for j in dir(i):                    if getattr(i,j) == cls:                        style = cls                        cls = i                        break                    elif type(cls) == int:            for i in dir(sizer):                if cls == getattr(sizer,i):                    style = cls                    cls = sizer                    break                        assert(style)                        self._style.append((cls,style))        if cls in (window,edit,listbox,static):            if "hwnd" in dir(self.parent):                if "_EX_" in style:                    win32gui.SetWindowLong(self.parent.hwnd, GWL_EXSTYLE,                                            getattr(win32con,style))                else:                    win32gui.SetWindowLong( self.parent.hwnd, GWL_STYLE,                                           getattr(win32con,style))            else:                if "_EX_" in style:                    self.parent._startup_ex_style |= getattr(win32con,style)                else:                    self.parent._startup_style = (self.parent._startup_style | getattr(win32con,style))                    def remove(self,cls,style):                try:            del self._style[self._style.index((cls,style))]            if cls in (window,edit,listbox,static):                if "_EX_" in style:                    style = win32gui.GetWindowLong(self.parent.hwnd,                                                   GWL_EXSTYLE)                    slong = getattr(win32con,style)                    win32gui.SetWindowLong(self.parent.hwnd, GWL_EXSTYLE,                                               style ^ slong)                else:                    style = win32gui.GetWindowLong(self.parent.hwnd,                                                   GWL_STYLE)                    slong = getattr(win32con,style)                    win32gui.SetWindowLong(self.parent.hwnd, GWL_STYLE,                                           style ^ slong)        except ValueError, e:            raise ValueError, "Style not setted."#!/usr/bin/env pythonimport windowimport Labelw = window.Window("teste de toolkit")#w.debug_events = Truee = Label.Label("oi mundo")def clicked(*args):    w.MsgBox("Hey, stop clicking me!")    #e.connect(window.WM_COMMAND,clicked)w.add(e)w.show_all()#e.append("oi mundo")#e.insert("ae galera!")#e.insert("ae galera!")#e.insert("ae galera!")#e.insert("ae galera!")#e.insert("ae galera!")#e.select(0)#window.main()window.win32gui.PumpMessages()#!/usr/bin/env pythonfrom wintk import *class widget_wrapper(widget):    classname = "widget_wrapper"    WidgetName = ""    Width = CW_USEDEFAULT    Height = CW_USEDEFAULT    DefaultSize = (-1,-1)    def __init__(self,title = ""):        self._evt_name = {}        self._pre_init()        self._register_wclass()                self.create_widget(title)        self.oldWinProc = win32gui.GetWindowLong(self.hwnd, GWL_WNDPROC)        win32gui.SetWindowLong(self.hwnd, GWL_WNDPROC,self._event_dispacher)        self.set_font(font.Font())                self.init()        self._post_init()                    def init(self):        pass        def _post_init(self):        if self.DefaultSize[1] == -1:            self.DefaultSize[1] = win32gui.GetTextExtentPoint32(win32gui.GetWindowDC(self.hwnd),win32gui.GetWindowText(self.hwnd))[1] + 2        if self.DefaultSize[0] == -1:            self.DefaultSize[0] = win32gui.GetTextExtentPoint32(win32gui.GetWindowDC(self.hwnd),win32gui.GetWindowText(self.hwnd))[0] + 2                self.resize(self.DefaultSize)    def create_widget(self,title):        self.hwnd = win32gui.CreateWindowEx(self._startup_ex_style,self.WidgetName,title,                        self._startup_style,0,0, self.Width, self.Height,0,0,                        win32api.GetModuleHandle(None), None)            def _register_wclass(self):        #creating event table, to translating when debug        for j in [i for i in dir(win32con) if i.startswith("WM_")]:            self._evt_name[getattr(win32con,j)] = j        def _event_dispacher(self,hwnd,Message,lParam,hParam):        if hwnd != self.hwnd:            return win32gui.CallWindowProc(self.oldWinProc,hwnd,Message,lParam,hParam)        flag = False        if self.debug_events:            if Message in self._evt_name:                evt_name = self._evt_name[Message]            else: evt_name = Message            print "evt: ", evt_name, lParam, hParam        if Message in self._connect_dict:            for i in self._connect_dict[Message]:                flag = i[1](hwnd,lParam,hParam,*i[2])                        if not flag:            return win32gui.CallWindowProc(self.oldWinProc,hwnd,Message,lParam,hParam)        else: return flag;    from wintk import *import timeclass Window(widget):    classname = "Window"    style = [style.window.OVERLAPPEDWINDOW]    def init(self, title="teste"):                self.hwnd = win32gui.CreateWindowEx(self._startup_ex_style, self.wclass,            title, self._startup_style, CW_USEDEFAULT,            CW_USEDEFAULT, CW_USEDEFAULT, CW_USEDEFAULT, 0, 0,        win32api.GetModuleHandle(None), None)        self.connect(WM_DESTROY, self.quit)        self.set_font(font.Font())    def __del__(self):        self.close()    def create_wclass(self,title="",classname="WinTK"):        self.container = []        wc = win32gui.WNDCLASS()        wc.style = 0         wc.lpfnWndProc = { }        wc.cbWndExtra = 0        wc.hInstance = win32api.GetModuleHandle(None)        wc.hIcon = win32gui.LoadIcon(0, IDI_APPLICATION)        wc.hCursor = win32gui.LoadCursor(0, IDC_ARROW)        wc.hbrBackground = win32gui.GetSysColorBrush(win32con.COLOR_3DFACE)        wc.lpszClassName = classname        self.wc = wc                def MsgBox(self,text,caption="",style="alert"):        MsgBox(text,caption,style,self)            def quit(self,*args):        win32gui.DestroyWindow(self.hwnd)        win32gui.PostQuitMessage(0)#!/usr/bin/env python# -*- encoding: utf-8 -*-#import winxpgui as win32guiimport win32guiimport win32conimport win32apiimport exceptionsimport win32processfrom win32con import *import ctypesuser32 = ctypes.windll.user32import styleimport fontimport sys#print sorted([getattr(win32con,i) for i in  dir(win32con) if i.startswith('WM')])#[0, 1, 1, 2, 2, 3, 3, 4, 5, 5, 6, 6, 7, 7, 8, 8, 10, 11, 12, 13, 14, 15, 16, 17,#18, 19, 20, 21, 22, 24, 26, 26, 27, 28, 29, 30, 31, 32, 33, 34, 35, 36, 38, 39,#40, 42, 43, 44, 45, 46, 47, 48, 49, 50, 51, 55, 57, 61, 65, 68, 70, 71, 72, 74,#75, 78, 80, 81, 82, 83, 84, 85, 123, 124, 125, 126, 127, 128, 129, 130, 131, 132,#133, 134, 135, 136, 160, 161, 162, 163, 164, 165, 166, 167, 168, 169, 256, 256,#257, 258, 259, 260, 261, 262, 263, 264, 269, 270, 271, 271, 272, 273, 274, 275,#276, 277, 278, 279, 287, 288, 289, 290, 291, 292, 293, 294, 306, 307, 308, 309,#310, 311, 312, 512, 512, 513, 514, 515, 516, 517, 518, 519, 520, 521, 522, 522,#528, 529, 530, 531, 532, 533, 534, 536, 537, 544, 545, 546, 547, 548, 549, 550,#551, 552, 553, 560, 561, 562, 563, 564, 641, 642, 643, 644, 645, 646, 648, 656,#657, 673, 675, 768, 769, 770, 771, 772, 773, 774, 775, 776, 777, 778, 779, 780,#781, 782, 783, 784, 785, 786, 791, 792, 856, 863, 864, 895, 896, 911, 1024, 1024,#1025, 1025, 1026, 1027, 1028, 1029, 1030, 1125, 1126, 32768]#event numbers printed, I think it is a signed short int, so the events above 20k#is freelly to use.WM_SOCKET = 20000 # for assync socket readingCB_SETMINVISIBLE = 0x1701EM_SETBKGNDCOLOR  = WM_USER + 67def MsgBox(text,caption="",style="alert", parent = None):    styles = {        "alert": MB_ICONERROR,        "warning": MB_ICONEXCLAMATION,        "info": MB_ICONINFORMATION    }    assert((style in styles.keys()))    style = styles[style]    if parent == None:        parent = 0    else:        parent = parent.hwnd     win32gui.MessageBox(parent,text,caption,style | MB_OK)#, win32api.MAKELANGID(LANG_NEUTRAL,SUBLANG_DEFAULT))    class widget:    classname = "widget"    type = "widget"    border = 4    parent = None    child = None    debug_events = False    _startup_style = 0    _startup_ex_style = 0    _evt_name = {}    _connect_id = 1    _connect_dict = {}    _add_pending = []    def __init__(self,*args,**kw):        self.create_wclass()        self._pre_init()        self._register_wclass()                self.init(*args,**kw)        self._post_init()        def init(self,*args,**kw):                raise NotImplementedError, "This is a virtual widget, can't initalize itself"        def _post_init(self):        pass        def _pre_init(self):        s = style.Style(self)        for i in self.style:            s.add(i)        self.style = s        def create_wclass(self):        raise NotImplementedError, "To create a widget, you need to create a wclass method"    def _register_wclass(self):        global WM_SOCKET        wproc = {}        #creating event table, to translating when debug        for j in [i for i in dir(win32con) if i.startswith("WM_")]:            self._evt_name[getattr(win32con,j)] = j            wproc[getattr(win32con,j)] = self._event_dispacher        wproc[WM_SOCKET] = self._event_dispacher        self.wc.lpfnWndProc = self._event_dispacher        self.wclass = win32gui.RegisterClass(self.wc)        del self.wc        def _event_dispacher(self,hwnd,Message,lParam,hParam):        flag = False                if Message == WM_SIZE:            self._on_resize()                    if Message == WM_SHOWWINDOW and lParam == 1:            try:                self.add_pennding()            except:                pass                    if self.debug_events:            if Message in self._evt_name:                evt_name = self._evt_name[Message]            else: evt_name = Message            print "evt: ", evt_name, lParam, hParam        if Message in self._connect_dict:            for i in self._connect_dict[Message]:                flag = i[1](hwnd,lParam,hParam,*i[2])                        if not flag:            return win32gui.DefWindowProc(hwnd,Message,lParam,hParam)        else: return flag;        def connect(self, event, callback, *args):        if event in self._connect_dict:            self._connect_dict[event].append([self._connect_id, callback,args])        else:            self._connect_dict[event] = [[self._connect_id, callback,args]]        r = self._connect_id        self._connect_id += 1        return r        def disconnect(self,id):        print self._connect_dict        for i in self._connect_dict.keys():            for j in xrange(i):                if id == i[j][0]:                    del i[j]                    return        def fit_to_parent(self):        if self.parent:            psize = self.parent.get_client_size()            ssize = list(self.get_size())            if (style.sizer, style.sizer.FIT_TO_PARENT) in self.style._style:                x = self.parent.border                y = self.parent.border                ssize = (psize[0] - self.parent.border * 2, psize[1] - self.parent.border * 2)            else:                #Vertical Resizing                if (style.sizer, style.sizer.VALIGN_MIDDLE) in self.style._style:                    y = (psize[1] - ssize[1]) / 2                elif (style.sizer, style.sizer.VALIGN_TOP) in self.style._style:                    y = self.parent.border                elif (style.sizer, style.sizer.VALIGN_BOTTOM) in self.style._style:                    y = psize[1] - self.parent.border - ssize[1]                elif (style.sizer, style.sizer.VEXPAND) in self.style._style:                    y = self.parent.border                    ssize[1] = psize[1] - self.parent.border * 2                                    #Horizontal Resizing                if (style.sizer, style.sizer.HALIGN_CENTER) in self.style._style:                    x = (psize[0] - ssize[0]) / 2                elif (style.sizer, style.sizer.HALIGN_LEFT) in self.style._style:                    x = self.parent.border                elif (style.sizer, style.sizer.HALIGN_RIGHT) in self.style._style:                    x = psize[0] - self.parent.border - ssize[0]                elif (style.sizer, style.sizer.HEXPAND) in self.style._style:                    x = self.parent.border                    ssize[0] = psize[0] - self.parent.border * 2                                self.move_resize((x,y),ssize)        def fit_to_child(self):        if self.child:            v, h = self.child.get_size()            self.child.move((self.border,self.border))            self.resize(v + self.border, h + self.border)        def _on_resize(self):        if self.child:            self.child.fit_to_parent()        if self.parent:            self.parent.fit_to_child()        def add_pennding(self):        self._add_pending = list(set(self._add_pending))        try:            for i in self._add_pending:                self.add(i,True)        finally:            self._add_pending = []                def add(self,widget,force = False):        if not win32gui.IsWindowVisible(self.hwnd) and not force:            self._add_pending.append(widget)            return        if self.child:            raise OverflowError, "no  possvel adicionar mais de um widget a um widget."                    if widget.type == "widget":            win32gui.SetWindowLong(widget.hwnd, GWL_STYLE, WS_CHILD)            win32gui.SetParent(widget.hwnd,self.hwnd)            self.child = widget            widget.parent = self            widget.fit_to_parent()            def get_client_rect(self):        return win32gui.GetClientRect(self.hwnd)            def get_rect(self):        return win32gui.GetWindowRect(self.hwnd)        def get_size(self):        r = self.get_rect()        return (r[2]-r[0],r[3]-r[1])        def get_client_size(self):        return self.get_client_rect()[2:]            def get_pos(self):        return self.get_rect()[:2]        def move(self,xy,repaint = True):        self.move_resize(xy,self.get_size(),repaint)        def resize(self,wh,repaint = True):        self.move_resize(self.get_pos(),wh,repaint)        def move_resize(self,xy,wh,repaint = True):        args = list(xy) + list(wh) + [repaint]        win32gui.MoveWindow(self.hwnd,*args)    #def move_resize(self,rect,repaint = True):    #    self.move_resize(self,rect[:2],(rect[2]-rect[0],rect[3]-rect[1]),repaint);            def show(self,show=True):        win32gui.ShowWindow(self.hwnd,show)        def show_all(self):        self.show()        if self.child:            self.child.show_all()        def set_font(self,font):        win32gui.SendMessage(self.hwnd,WM_SETFONT,font.handle)            def close(self):        win32gui.DestroyWindow(self.hwnd)