Exemple #1
0
class DemoLabel(twf.TableLayout):
    demo_for = twf.Label
    title = twf.TextField()
    xx = twf.Label(
        text='Please enter as much information as possible in the description.'
    )
    description = twf.TextArea()
Exemple #2
0
    def __init__(self, app):
        super().__init__(app)
        self.app.content_game = self
        self.content = _ContentGame(app, self)
        self.content.move(0, 0)
        self.setFixedSize(self.content.width() + 400, self.content.height())
        self.color_lbl = widgets.Label('({})'.format(app.color),
                                       self,
                                       200,
                                       50,
                                       900,
                                       100,
                                       alignment='center')
        self.vs_lbl = widgets.Label('playing vs.',
                                    self,
                                    200,
                                    50,
                                    900,
                                    150,
                                    alignment='center')
        self.opponent_lbl = widgets.Label(app.opponent,
                                          self,
                                          200,
                                          50,
                                          900,
                                          200,
                                          alignment='center')
        self.opponent_color_lbl = widgets.Label('({})'.format(
            app.opponent_color),
                                                self,
                                                200,
                                                50,
                                                900,
                                                250,
                                                alignment='center')
        self.turn_lbl = widgets.Label('',
                                      self,
                                      200,
                                      50,
                                      900,
                                      400,
                                      alignment='center')

        self.give_up_btn = widgets.PushButton('Give up', self, 200, 100, 900,
                                              600, app.send_give_up)

        self.repaint()
 def setUp(self):
     self.name = 'Label_1'
     self.type = 'label'
     self.x = 10
     self.y = 12
     self.width = 14
     self.height = 15
     self.text = 'TEST Label'
     self.element = widgets.Label(self.name, self.text, self.x, self.y,
                                  self.width, self.height)
Exemple #4
0
 def __init__(self, app):
     super().__init__(app)
     self.waiting_lbl = widgets.Label('Please, wait...',
                                      self,
                                      400,
                                      100,
                                      400,
                                      100,
                                      alignment='center')
     self.go_back_btn = widgets.PushButton('Go Back', self, 400, 100, 400,
                                           250, app.go_back)
    def __init__(self, window, x=0, y=0, z=0, width=None, height=None):
        super(GUI, self).__init__()
        self.window = window
        self.style = style.Style()

        # element.Element stuff
        self.x, self.y, self.z = x, y, z
        self.width = self.inner_width = width or window.width
        self.height = self.inner_height = height or window.height
        self.children = []

        # map Element id, class and name to Element
        self._by_id = {}
        self._by_class = collections.defaultdict(set)
        self._by_name = collections.defaultdict(set)

        # list Element.ids in the order they're registered for tabbing
        self._focus_order = []

        self.debug_display = None
        self.debug = '--debug' in sys.argv
        if self.debug:
            self.debug_display = widgets.Label(self, 'dummy',
                bgcolor="white", padding=1, width=self.width)
Exemple #6
0
    def build_client_widgets(self, client):
        d = {
            'tgltest1': {
                'cls': widgets.Toggle
            },
            'btntest1': {
                'cls': widgets.Button
            },
            'fdrtest1': {
                'cls': widgets.Fader,
                'group': 'Dimmer',
                'attr': 'value'
            },
            'xytest1': {
                'cls': widgets.xyPad,
                'group': 'Position',
                'attr': 'value_seq'
            },
            'label1': {
                'cls': widgets.Label
            }
        }
        self.testwidgets.update({client: {}})
        for name, info in d.iteritems():
            w_kwargs = dict(osc_address=name,
                            osc_parent_node=self.osc_node,
                            label=name,
                            client=client)
            if 'group' in info:
                g = self.MainController.Selection.AttributeGroups[
                    info['group']]
                w_kwargs.update({
                    'src_object': g,
                    'src_attr': info['attr'],
                    'src_signal': 'value_changed'
                })
            w = info['cls'](**w_kwargs)
            w.connect('value_update', self.on_testwidget_update)
            self.testwidgets[client].update({name: w})
            w.set_link_state(True)
        for x in range(1, 9):
            csnode = self.osc_node.add_new_node(name='CueStack')
            btnnode = csnode.add_new_node(name='push')
            lblnode = csnode.add_new_node(name='label')

            w_kwargs = dict(osc_address=str(x), client=client)
            stack = self.MainController.CueStacks.values()[0]
            snapshot = stack.snapshots_indexed.get(x)
            if snapshot:
                w_kwargs.update({
                    'src_object': snapshot,
                    'src_attr': 'active',
                    'src_signal': 'active_changed',
                    'osc_parent_node': btnnode
                })
                w = widgets.Button(**w_kwargs)
                self.testwidgets[client].update(
                    {'/'.join(['push', w.osc_address]): w})
                w.set_link_state(True)
                w_kwargs.update({
                    'src_attr': 'name',
                    'src_signal': 'property_changed',
                    'osc_parent_node': lblnode,
                    'label': snapshot.name
                })
                w = widgets.Label(**w_kwargs)
                self.testwidgets[client].update(
                    {'/'.join(['push', w.osc_address]): w})
                w.set_link_state(True)
    def __init__(self, screen):
        MenuScreen.__init__(self, screen, 'Hotseat Setup')
        self.listsize = (gwglob.MID_FONT.size('W' * gwglob.PLAYER_MAXNAME)[0] +
                         20, gwglob.MID_FONT_SIZE[1] * gwglob.PLAYER_MAX + 20)
        self.menu = widgets.Menu(self, (100, self.page))
        self.add = widgets.Button(self,
                                  (90, self.page + self.listsize[1] + 10),
                                  'Add', self.addplayer,
                                  widgets.STYLE_MID_FONT)
        self.remove = widgets.Button(
            self,
            (90 + self.add.width + 10, self.page + self.listsize[1] + 10),
            'Remove', self.removeplayer, widgets.STYLE_MID_FONT, True)
        name = widgets.Label(self, (110 + self.listsize[0], self.page - 10),
                             'Name:', widgets.STYLE_MID_FONT)
        color = widgets.Label(
            self, (110 + self.listsize[0], self.page + name.height + 5),
            'Color:   ', widgets.STYLE_MID_FONT)
        self.name = widgets.Entry(
            self, (123 + self.listsize[0] + color.width, self.page - 10),
            'Player 1', gwglob.PLAYER_MAXNAME, widgets.STYLE_MID_FONT)
        self.color = widgets.ColorDisplay(
            self, (110 + self.listsize[0] + color.width,
                   self.page + name.height + 5),
            (color.height - 6, color.height - 6), (255, 0, 0))
        self.red = widgets.ColorBar(
            self, (110 + self.listsize[0] + color.width,
                   self.page + name.height + color.height + 10), (255, 10), 0,
            255)
        self.green = widgets.ColorBar(
            self, (110 + self.listsize[0] + color.width,
                   self.page + name.height + color.height + 30), (255, 10), 1)
        self.blue = widgets.ColorBar(
            self, (110 + self.listsize[0] + color.width,
                   self.page + name.height + color.height + 50), (255, 10), 2)
        start = widgets.Button(self, (0, 0), 'Start', self.start,
                               widgets.STYLE_BIG_FONT)
        start.topright = (gwglob.SIZE[0] / 2 - 5,
                          gwglob.SIZE[1] - start.height - 100)
        exit = widgets.Button(self, (0, 0), 'Exit', self.exit,
                              widgets.STYLE_BIG_FONT)
        exit.topleft = (gwglob.SIZE[0] / 2 + 5,
                        gwglob.SIZE[1] - start.height - 100)
        self.profiles = widgets.ButtonDropDown(
            self, (110 + self.listsize[0] + color.width,
                   self.name.topleft[1] + self.name.height / 2 - 6))

        def drawicon(b=None, pos=None):
            if b == None:
                return (5, 5)
            c = widgets.STYLE_MID_FONT.color(b)
            pygame.draw.line(b.screen, c, (pos[0] + 2, pos[1]),
                             (pos[0] + 2, pos[1] + 4))
            pygame.draw.line(b.screen, c, (pos[0], pos[1] + 2),
                             (pos[0] + 4, pos[1] + 2))

        add = widgets.IconButton(
            self, (125 + self.listsize[0] + color.width + self.name.width,
                   self.name.topleft[1] + self.name.height / 2 - 6), drawicon,
            self.addprofile)
        self.pack(self.menu)
        self.pack(self.add)
        self.pack(self.remove)
        self.pack(name)
        self.pack(color)
        self.pack(self.name)
        self.pack(self.color)
        self.pack(self.red)
        self.pack(self.green)
        self.pack(self.blue)
        self.pack(start)
        self.pack(exit)
        self.pack(add)
        self.pack(self.profiles)
        self.addplayer()
        self.addplayer(select=False)
        for text, color in gwglob.SETTINGS.get('profiles', []):
            self.addprofile(None, text, color)
        ''' for EntryLabel '''
        validate.run_validator(widg)

    def get_event(evt):
        ''' for widgets other than EntryLabel '''
        widg = evt.widget
        validate.run_validator(widg)

    date_in = ''
    validate = ValidDate

    root = tk.Tk()
    root.geometry('+10+600')

    label = wdg.Label(root,
                      text='Dates validation procedure must work equally\n'
                      'from any kind of input widget')
    label.grid(columnspan=3, pady=24)

    simple = wdg.Entry(root)
    simple.grid(column=0, row=1)
    simple.insert(0, '1810 10 18')
    simple.focus_set()

    mostring = wdg.Entry(root)
    mostring.grid(column=1, row=1)
    mostring.insert(0, '1912 4 jan')

    clarif3 = wdg.Entry(root)
    clarif3.grid(column=2, row=1)
    clarif3.insert(0, '11 oct 0012 ad to 1884 bc')
Exemple #9
0
    def drawWidgets(self):
        # First create column headers
        pad = (1, 1)
        for j in range(self.noColumns):
            # widgetFrame = TK.Frame(self.tableFrame,width=self.columns[j]['width'],
            #                        height=DEFAULTCELLHEIGHT)
            # widgetFrame.pack_propagate(0) # Stops child widgets of label_frame from resizing it
            cell = widgets.Label(self.tableFrame)
            cell.configure(bg=self.columns[j]['bg'],
                           fg=self.columns[j]['fg'],
                           relief=TK.RAISED)
            #cell.config(width=self.columns[j]['width'])

            cell.grid(row=0, column=j, sticky='ew')
            #cell.pack(expand=TK.YES, fill=TK.BOTH)
            cell.setText(self.columns[j]['text'])
            cell.tableRow = -1
            cell.tableColumn = j
            cell.bind("<Button-1>", self._click)
            pad = (1, 1)
            if j == 0: pad = (2, 1)
            if j == self.noColumns - 1: pad = (1, 2)
            #widgetFrame.grid(row=0, column=j, padx=pad, pady=(2,1))

        # Second create cell widgets
        for i in range(self.visibleRows):
            widgetRow = []
            for j in range(self.noColumns):
                widgetName = self.columns[j].get('widget',
                                                 'Label')  # Default to label
                # widgetFrame = TK.Frame(self.tableFrame,width=self.columns[j]['width'],
                #                        height=DEFAULTCELLHEIGHT) #,
                # widgetFrame.pack_propagate(0) # Stops child widgets of label_frame from resizing it
                if widgetName == 'Textbox':
                    cellWidget = widgets.Textbox(self.tableFrame)
                    #cellWidget.config(width=columns[j]['width')
                    cellWidget.bind('<Return>', self._dataChanged)
                    cellWidget.bind('<Escape>', self._cancelChange)
                    cellWidget.bind("<FocusOut>", self._dataChanged)
                    #cellWidget.bind("<Leave>", self._click) # Must decide if this is sensible behaviour
                elif widgetName == 'Button':
                    cellWidget = widgets.Button(
                        self.tableFrame)  #, command=self._dataChanged)
                    cellWidget.bind('<ButtonRelease>', self._dataChanged)
                    # cellWidget.config(command=self.dataChanged)
                elif widgetName == 'Checkbox':
                    cellWidget = widgets.Checkbox(self.tableFrame)
                elif widgetName == 'Combobox':
                    cellWidget = widgets.Combobox(self.tableFrame)
                    cellWidget.bind("<<ComboboxSelected>>", self._dataChanged)
                else:
                    cellWidget = widgets.Label(self.tableFrame)
                    cellWidget.config(relief=TK.RAISED)
                cellWidget.config(width=self.columns[j]['width'])
                cellWidget.widgetType = widgetName
                #cellWidget.pack(expand=TK.YES, fill=TK.BOTH)
                align = self.columns[j].get('align', '')
                if align:
                    cellWidget.configure(anchor=ANCHOR[align])
                cellWidget.grid(row=i + 1, column=j, stick='ew')
                cellWidget.setText('')
                cellWidget.tableRow = i
                cellWidget.tableColumn = j
                cellWidget.dataCoords = [
                ]  # The row/column in the data matrix - set when table populated
                cellWidget.bind("<Button-1>", self._click)
                widgetRow.append(cellWidget)
                pad = (1, 1)
                ypad = (1, 1)
                if j == 0: pad = (2, 1)
                if j == self.noColumns - 1: pad = (1, 2)
                if i == self.visibleRows - 1: ypad = (1, 2)
                #widgetFrame.grid(row=i+1, column=j, padx=pad, pady=ypad)
            self.widgets.append(widgetRow)
        if self.data:
            if len(self.data) > self.visibleRows:
                self.scroll = True
                col = len(self.columns)
                x = len(self.data) - self.visibleRows
                self.addVerticalScroll(x)
                #self.vertical_scroll = TK.Scale(self.tableFrame, orient=TK.VERTICAL, from_=0, to=x, command=self.v_scroll, showvalue=0)
                #self.vertical_scroll.grid(row=1,column=col, rowspan=self.visibleRows, sticky=TK.N+TK.S)
        elif self.scroll:
            col = len(self.columns)
            x = 0
            self.addVerticalScroll(x)
            #self.vertical_scroll = TK.Scale(self.tableFrame, orient=TK.VERTICAL, from_=0, to=x, command=self.v_scroll, showvalue=0)
            #self.vertical_scroll.grid(row=1,column=col, rowspan=self.visibleRows, sticky=TK.N+TK.S)

        # Get parent frame width and height - x and y coordinates can also be accessed
        self.tableFrame.update(
        )  # Required to get frame width and height at this time
        self.width = self.tableFrame.winfo_width()
        self.height = self.tableFrame.winfo_height()
Exemple #10
0
    dates.get_widg_type(widg)


def get_event(evt):
    ''' for widgets other than EntryLabel '''
    widg = evt.widget
    dates.get_widg_type(widg)


date_in = ''

root = tk.Tk()
root.geometry('+10+600')

label = wdg.Label(root,
                  text='Dates validation procedure must work equally\n'
                  'from any kind of input widget')
label.grid(columnspan=3, pady=24)

simple = wdg.Entry(root)
simple.grid(column=0, row=1)
simple.insert(0, '1810 10 18')
simple.focus_set()

mostring = wdg.Entry(root)
mostring.grid(column=1, row=1)
mostring.insert(0, '1912 4 jan')

clarif3 = wdg.Entry(root)
clarif3.grid(column=2, row=1)
clarif3.insert(0, '11 oct 0012 ad to 1884 bc')
Exemple #11
0
 def set_title(self, title, font_size=None):
     self.items['title'] = w.Label(
         self.cont.lv_obj, title, font_size=font_size)