當前位置: 首頁>>代碼示例>>Python>>正文


Python base.Widget類代碼示例

本文整理匯總了Python中base.Widget的典型用法代碼示例。如果您正苦於以下問題:Python Widget類的具體用法?Python Widget怎麽用?Python Widget使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Widget類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: __init__

 def __init__(self,pos, size, steps=10,\
              transparent=False, backcol=GREY, barfcol=DEEPSKYBLUE4, barbcol=BLACK):
     """pos is the postion to place this widget
     size is a tuple with the width and height of the widget
     steps is the amount of steps that should be taken to fill the bar, defaults to 10
     The update call returns the number of steps taken, when the bar is full it will return False
     """
     Widget.__init__(self)
     self.end = size[0]
     self.step = self.end / steps
     self.steps = steps
     self.backcol = backcol
     self.barfcol = barfcol
     self.barbcol = barbcol
     
     self.image = pygame.Surface((size[0],size[1]))
     self.image.fill(backcol)
     self.rect = self.image.get_rect()
     pygame.draw.rect(self.image, barbcol, self.rect.inflate(-8,-8),0)
             
     self.barsurf = pygame.Surface((size[0]-8,size[1]-8))
     self.barsurf.fill(barfcol)
     self.barrect =  self.barsurf.get_rect()
     self.barend = self.step        
     self._initbar()
     self.moveto(pos)
開發者ID:childsplay-mobi,項目名稱:cp-pygame,代碼行數:26,代碼來源:dialogs.py

示例2: __init__

 def __init__(self, place, **kwds):
     wx.MenuBar.__init__(self)
     self.frame = place[0]
     Widget.__init__(self, place, **kwds)
     self.frame.Bind(wx.EVT_MENU, self.on_menu)
     self.menus = {}
     self.items = {}
開發者ID:BackupTheBerlios,項目名稱:grafity-svn,代碼行數:7,代碼來源:commands.py

示例3: __init__

    def __init__(self, parent=None, num_tiles=128, num_frames=64, *args, **kwargs):
        Widget.__init__(self)
        Frame.__init__(self, parent, *args, **kwargs)

        self.num_frames = num_frames
        self.num_tiles = num_tiles
        self.frames = {}
開發者ID:zackbloom,項目名稱:serial_bot_ui,代碼行數:7,代碼來源:camera.py

示例4: __init__

    def __init__(self, place, data=None, columns=None, headers=False, editable=False, 
                 connect={}, **kwds):
        flags = wx.LC_REPORT|wx.LC_VIRTUAL|wx.BORDER_SUNKEN
        if not headers:
            flags |= wx.LC_NO_HEADER
        if editable:
            flags |= wx.LC_EDIT_LABELS

        _xListCtrl.__init__(self, self, place[0], -1, style=flags)
        Widget.__init__(self, place, connect, **kwds)

        if data is None:
            data = ListData()

        if columns is None:
            columns = [None]

        self.selection = []

        self._columns = columns
        self._data = data
        if hasattr(self._data, 'connect'):
            self._data.connect('modified', self.update)

        self.update()

        self.Bind(wx.EVT_LIST_ITEM_ACTIVATED, self.on_item_activated)
        for event in (wx.EVT_LIST_ITEM_SELECTED, wx.EVT_LIST_ITEM_DESELECTED, wx.EVT_LIST_ITEM_FOCUSED):
            self.Bind(event, self.on_update_selection)

        self.can_drop = False
        self.drop_formats = []

        self.Bind(wx.EVT_RIGHT_DOWN, self.on_right_click)
開發者ID:BackupTheBerlios,項目名稱:grafity-svn,代碼行數:34,代碼來源:listctrl.py

示例5: __init__

 def __init__(self, rect, fsize, bgcol=None, fgcol=None, padding=8, border=2, lines=1):
     """Starts empty, use set_text to fill it.
     rect - Rect indicating the size of the box and position. 
     fsize - Font size
     fgcol - text color (R,G,B), if None the theme color will be used.
     bgcol - background color (R,G,B), if None the theme color will be used.
             If bgcol is set to 'trans' the background will be transparent.
     padding - space in pixels around the text
     border - border in pixels, None means no border.
     lines - how many previous lines of text should be visible (cheap scroll effect)
             """
     if not fgcol: 
         fgcol = self.THEME['textview_fg_color']
     if not bgcol:
         bgcol = self.THEME['textview_bg_color']
     self.fgcol = fgcol
     self.bgcol = bgcol
     self.padding = padding
     self.fsize = fsize
     self.image = pygame.Surface(rect.size)
     self.image.fill(self.bgcol)
     self.rect = self.image.get_rect()
     if border:
         pygame.draw.rect(self.image, BLACK, self.rect, border)
     self.org_image = self.image.copy()
     Widget.__init__(self, self.image)
     self.rect.move_ip(rect.topleft)
     self.prevlines = []
     self.lines = lines
開發者ID:childsplay-mobi,項目名稱:cp-pygame,代碼行數:29,代碼來源:text.py

示例6: __init__

 def __init__(self, parent=None, statusbar=False, connect={}, **kwds):
     wx.Frame.__init__(self, parent, -1)
     Widget.__init__(self, None, connect, **kwds)
     Container.__init__(self)
     if statusbar:
         self.CreateStatusBar()
     self.parent = parent
開發者ID:BackupTheBerlios,項目名稱:grafity-svn,代碼行數:7,代碼來源:window.py

示例7: __init__

 def __init__(self, txt, pos=(0, 0), fsize=18, padding=4, name='', fbold=True, **kwargs):
     """Button which shows a text
     txt - string to display
     pos - position to display the box
     fsize - Font size
     padding - space in pixels around the text
     name - string to indicate this object
     kwargs - bgcol, fgcol
     """
     Widget.__init__(self)
     if kwargs.has_key('fgcol'):
         fgcol = kwargs['fgcol']
     else:
         fgcol = self.THEME['button_fg_color']
     self.kwargs = kwargs
     self.ImSelected = False
     if type(txt) in (types.StringType, types.UnicodeType):
         s = utils.char2surf(txt, fcol=fgcol, fsize=fsize, ttf=TTF, bold=fbold)
         r = s.get_rect()
         r.w += padding*2
         r.h += padding*2
     else:
         s = txt
         r = s.get_rect()
         r.w += padding*2
         r.h += padding*2
     if kwargs.has_key('maxlength') and r.w > kwargs['maxlength']:
         r.w = kwargs['maxlength']
     self.pos = pos
     self.padding = padding
     self.name = name
     self.r = r
     self._setup(s)
開發者ID:childsplay-mobi,項目名稱:cp-pygame,代碼行數:33,代碼來源:buttons.py

示例8: __init__

 def __init__(self, place, multiline=False, connect={}, **kwds):
     style = 0
     if multiline:
         style |= wx.TE_MULTILINE
     else:
         style |= wx.TE_PROCESS_ENTER
     wx.TextCtrl.__init__(self, place[0], -1, style=style)
     Widget.__init__(self, place, connect, **kwds)
開發者ID:BackupTheBerlios,項目名稱:grafity-svn,代碼行數:8,代碼來源:text.py

示例9: __init__

    def __init__(self, place, **args):
        ScrolledPanel.__init__(self, place[0], -1)#, style=wx.SUNKEN_BORDER)
        Widget.__init__(self, place, **args)
        Container.__init__(self)

        self.layout = wx.BoxSizer(wx.VERTICAL)
        self.SetSizer(self.layout)
        self.SetAutoLayout(True)
        self.SetupScrolling()
開發者ID:BackupTheBerlios,項目名稱:grafity-svn,代碼行數:9,代碼來源:containers.py

示例10: __init__

    def __init__(self, place, connect={}, **kwds):
        wx.Notebook.__init__(self, place[0], -1)
        Widget.__init__(self, place, connect, **kwds)

        # item images
        self.imagelist = wx.ImageList(16, 16)
        self.SetImageList(self.imagelist)
        self.pixmaps = {}

        self.pages = []
開發者ID:BackupTheBerlios,項目名稱:grafity-svn,代碼行數:10,代碼來源:containers.py

示例11: _setup

    def _setup(self):
        # get all the surfaces
        title = utils.char2surf(self.title, 24, ttf=TTF, fcol=self.THEME['dialog_title_fg_color'], bold=True)
        
        if type(self.txt) == types.ListType or type(self.txt) in types.StringTypes:
            tv = TextView(self.txt, (0, 0), pygame.Rect(0, 0, self.dialogwidth, 400),\
                           bgcol='trans',fsize=self.fsize ,\
                          fgcol=self.THEME['dialog_fg_color'], autofit=True, bold=self.fbold)
        else: # we assume a SPWidget.Widget object
            tv = self.txt
        b = self.buttons_list[0]
        # start building dialog
        if self.dialogwidth and self.dialogheight:
            r = pygame.Rect(0, 0, self.dialogwidth, self.dialogheight)
        else:
            r = pygame.Rect(0, 0, max(self.butspace,(tv.rect.w + (self.padding * 2)),100), \
                        title.get_rect().h + 8 + b.rect.h + tv.rect.h + (self.padding*3))
        if r.w > 750:
            r.w = 750
        if r.h > 530:
            r.h = 530
        dlgsurf, dlgsizes = make_dialog_bg_dynamic(r.w+50, r.h+70, self.THEME)
        
        r = dlgsurf.get_rect()
        if not self.pos:
            y = max(10, (600 - r.h) / 2)
            x = (800 - r.w) / 2
            self.pos = (x, y)

        y = 10
        x = 20
        dlgsurf.blit(title, (x,y))
        dlgsurf.blit(tv.image, (x, dlgsizes['title_area'].h))
        
        Widget.__init__(self, dlgsurf)
        
        self.image = dlgsurf

        self.rect.move_ip(self.pos)
        for k, v in dlgsizes.items():
            dlgsizes[k].move_ip(self.pos)
        x = self.rect.left + ((self.rect.w - (self.butspace + 16 * len(self.buttons_list))) / 2)
        y = self.rect.bottom - self.buttons_list[0].rect.h *2
        if len(self.buttons_list) == 2:
            x = self.rect.left + 16
            self.buttons_list[0].moveto((x, y), True)
            x = self.rect.right - (self.buttons_list[1].rect.w + 16)
            self.buttons_list[1].moveto((x, y), True)
        else:
            for b in self.buttons_list:
                b.moveto((x, y), True)
                x += b.rect.w + 16
        self.dlgsizes = dlgsizes
開發者ID:childsplay-mobi,項目名稱:cp-pygame,代碼行數:53,代碼來源:dialogs.py

示例12: __init__

    def __init__(self, parent=None, max_val=180, *args, **kwargs):
        Widget.__init__(self)
        Canvas.__init__(self, parent, borderwidth=0, *args, **kwargs)

        self.line = None
        self.label = None
        self.max_val = max_val
        self.color = 'black'
        self.text_margin_bottom = 20

        self.size = min(int(self.cget('width')), int(self.cget('height')))
        self.create_arc(0, 0, self.size, self.size * 2, extent=180, fill='white')
開發者ID:zackbloom,項目名稱:serial_bot_ui,代碼行數:12,代碼來源:angle.py

示例13: __init__

    def __init__(self, place, **kwds):
        _xTreeCtrl.__init__(self, self, place[0])
        Widget.__init__(self, place, **kwds)
        self.roots = []
        self.items = []

        self.SetIndent(10)

        self.imagelist = wx.ImageList(16, 16)
        self.SetImageList(self.imagelist)
        self.pixmaps = {}

        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_sel_changed)
        self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.on_label_edit)

        self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.on_expand)
        self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.on_collapse)

        self.tree = self
        self.selection = None
開發者ID:BackupTheBerlios,項目名稱:grafity-svn,代碼行數:20,代碼來源:tree.py

示例14: __init__

    def __init__(self, place):
        wx.glcanvas.GLCanvas.__init__(self, place[0], -1, style=wx.glcanvas.WX_GL_DOUBLEBUFFER)
#        , attribList =[wx.glcanvas.WX_GL_DOUBLEBUFFER])
        Widget.__init__(self, place)

        self.init = False

        self.Bind(wx.EVT_ERASE_BACKGROUND, self.OnEraseBackground)
        self.Bind(wx.EVT_SIZE, self.OnSize)
        self.Bind(wx.EVT_PAINT, self.OnPaint)
        
        for event in (wx.EVT_LEFT_DOWN, wx.EVT_MIDDLE_DOWN, wx.EVT_RIGHT_DOWN):
            self.Bind(event, self.OnMouseDown)
        for event in (wx.EVT_LEFT_UP, wx.EVT_MIDDLE_UP, wx.EVT_RIGHT_UP):
            self.Bind(event, self.OnMouseUp)
        for event in (wx.EVT_LEFT_DCLICK, wx.EVT_MIDDLE_DCLICK, wx.EVT_RIGHT_DCLICK):
            self.Bind(event, self.OnMouseDoubleClicked)
        self.Bind(wx.EVT_MOTION, self.OnMouseMotion)
        self._lastsize = (-1, -1)

        self.Bind(wx.EVT_KEY_DOWN, self.OnKeyDown)    
開發者ID:BackupTheBerlios,項目名稱:grafity-svn,代碼行數:21,代碼來源:opengl.py

示例15: __init__

    def __init__(self, place, data=None, **kwds):
        _xTreeCtrl.__init__(self, self, place[0])
        Widget.__init__(self, place,  **kwds)

        self.data = data
        
        self.root = None
        self.items = TwoWayDict()
        self.selection = None

        self.SetIndent(10)

        self.imagelist = wx.ImageList(16, 16)
        self.SetImageList(self.imagelist)
        self.pixmaps = {}

        self.Bind(wx.EVT_TREE_SEL_CHANGED, self.on_sel_changed)
        self.Bind(wx.EVT_TREE_END_LABEL_EDIT, self.on_label_edit)

#        self.Bind(wx.EVT_TREE_ITEM_EXPANDED, self.on_expand)
#        self.Bind(wx.EVT_TREE_ITEM_COLLAPSED, self.on_collapse)

        self._skip_event = False
開發者ID:BackupTheBerlios,項目名稱:grafity-svn,代碼行數:23,代碼來源:tree.py


注:本文中的base.Widget類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。