示例#1
0
    def createTextPadGroup(self):
        groupBox = QGroupBox('Codeeditor')
        # tabWidthBox

        label1 = Label('Width for <Tab> in whitespaces:')

        self.tabWidthBox = QSpinBox()
        self.tabWidthBox.setMinimum(2)
        self.tabWidthBox.setMaximum(10)
        tab = int(self.c.getTab())
        self.tabWidthBox.setValue(tab)

        label2 = Label('Font size:')

        self.fontBox = QSpinBox()
        self.fontBox.setMinimum(6)
        self.fontBox.setMaximum(30)
        font = int(self.c.getFont())
        self.fontBox.setValue(font)

        label3 = WhiteLabel(
            'Changes in this area will be appear on\nrestart or new Tab')
        vbox = QVBoxLayout()

        vbox.addWidget(label1)
        vbox.addWidget(self.tabWidthBox)
        vbox.addWidget(label2)
        vbox.addWidget(self.fontBox)
        vbox.addWidget(label3)

        groupBox.setLayout(vbox)

        return groupBox
示例#2
0
    def make_menus(self):

        menu = Label(self.master.menu, text='menu bar')
        icon1 = Label(self.master.ribbon, text='ribbon menu')

        menu.grid()
        icon1.grid()
示例#3
0
def startResultsScreen(techMechsSaved, saveRequirement):
    global continueResults, savedText, requiredText, finalText

    continueResults = True
    savedText = Label(0, 0,
                      "You saved " + str(techMechsSaved) + " Tech Mechs.")
    requiredText = Label(0, 50,
                         "You needed " + str(saveRequirement) + " Tech Mechs.")
    if techMechsSaved >= saveRequirement:
        finalText = Label(0, 100, "Congratulations! You beat the level!")
    else:
        finalText = Label(0, 100, "Too bad! You didn't save enough.")
示例#4
0
    def make_widgets(self):

        self.make_scrollbars()

        self.make_menus()

        scridth = 20
        scridth_n = Frame(self, height=scridth)
        scridth_w = Frame(self, width=scridth)
        header = Frame(self)
        heading = LabelH3(header, text='header text')
        self.main_tabs = Frame(self)
        persons_tab = Frame(self.main_tabs)
        footer = Frame(self)
        boilerplate = Label(footer, text='footer')

        current_person_area = Frame(persons_tab)
        current_person = LabelH3(current_person_area)
        right_panel = Frame(persons_tab)
        attributes_table = Label(right_panel, text='attributes table')

        findings_table = EventsTable(persons_tab, self.view, self.treebard)

        # children of self
        scridth_n.grid(column=0, row=0, sticky='ew')
        scridth_w.grid(column=0, row=1, sticky='ns')
        header.grid(column=1, row=1, sticky='ew')
        self.columnconfigure(1, weight=1)
        self.rowconfigure(2, weight=1)
        self.main_tabs.grid(column=1, row=2, sticky='ew')
        footer.grid(column=1, row=3, sticky='ew')

        # children of header
        heading.grid(column=0, row=0, sticky='ew')

        # children of self.main_tabs
        persons_tab.grid(column=0, row=0, sticky='news')

        # children of persons_tab
        current_person_area.grid(column=0, row=0, sticky='w')
        right_panel.grid(column=1, row=0, sticky='e')
        findings_table.grid(column=0, row=1, columnspan=2, sticky='news')

        # children of current_person_area
        current_person.grid(column=0, row=0, sticky='w')

        # children of right_panel
        attributes_table.grid(column=0, row=0, sticky='news')

        # children of footer
        boilerplate.grid()
示例#5
0
    def __init__(self, title, content=None, is_open=True, align=HALIGN_CENTER):
        Control.__init__(self)
        if align == HALIGN_LEFT:
            left_expand = False
            right_expand = True
        elif align == HALIGN_CENTER:
            left_expand = True
            right_expand = True
        else:  # HALIGN_RIGHT
            left_expand = True
            right_expand = False

        self.is_open = is_open
        self.folding_content = content
        self.book = Graphic(self._get_image_path())

        self.header = HorizontalLayout([
            Graphic(path=["section", "left"], is_expandable=left_expand),
            Frame(HorizontalLayout([
                self.book,
                Label(title, path=["section"]),
            ]),
                  path=["section", "center"],
                  use_bg_group=True),
            Graphic(path=["section", "right"], is_expandable=right_expand),
        ],
                                       align=VALIGN_BOTTOM,
                                       padding=0)
        layout = [self.header]
        if self.is_open:
            layout.append(content)

        VerticalLayout.__init__(self, content=layout, align=align)
示例#6
0
    def __init__(self, disp, buttons, tim):
        super().__init__(name="Name",
                         display=disp,
                         buttons=buttons,
                         timer=tim,
                         btn_b=self.btn_b)
        cont = self.get_cont()
        cont.set_center()

        first, nick, last = self.get_name()

        self.add_item("firstname", Label(cont.lv_obj, first))
        self.add_item("nickname", Label(cont.lv_obj, nick, font_size=28))
        self.add_item("lastname", Label(cont.lv_obj, last))

        self.load_screen()
示例#7
0
    def __init__(self, text="", ok="Ok", cancel="Cancel",
                 window=None, batch=None, group=None, theme=None,
                 on_ok=None, on_cancel=None):
        def on_ok_click(dialog=None):
            if on_ok is not None:
                on_ok(self)
            self.teardown()

        def on_cancel_click(dialog=None):
            if on_cancel is not None:
                on_cancel(self)
            self.teardown()

        return Dialog.__init__(self, content=Frame(
            VerticalLayout([
                Label(text),
                HorizontalLayout([
                    Button(ok, on_click=on_ok_click),
                    None,
                    Button(cancel, on_click=on_cancel_click)
                ]),
            ])),
            window=window, batch=batch, group=group,
            theme=theme, movable=True,
            on_enter=on_ok_click, on_escape=on_cancel_click)
示例#8
0
    def make_colors_table(self, colors):

        def clear_select(evt):
            evt.widget.selection_clear()

        l_col = [
            'background 1', 'background 2', 'background 3', 'font color']

        self.h1.grid(
            column=0, row=0, 
            sticky='ew', 
            ipady=3,
            pady=6)

        self.h2.grid(
            column=1, row=0, 
            sticky='ew', 
            ipady=3,
            pady=6)

        self.entries_combos = []
        j = 1
        for name in l_col:
            lab = Label(
                self.colors_table,
                anchor='w',
                text=name)
            lab.grid(column=0, row=j, sticky='ew', padx=(6,12), pady=3)
            ent = Entry(self.colors_table, width=12)
            self.r_col[name] = ent
            ent.grid(column=1, row=j, pady=3)
            self.entries_combos.append(ent)
            ent.bind('<FocusOut>', clear_select)
            ent.bind('<Double-Button-1>', self.open_color_chooser)
            j += 1
示例#9
0
    def initUI(self):
        vbox = QVBoxLayout()
        hbox = QHBoxLayout()
        grid = QGridLayout()

        runLabel = Label('Run Command: ')

        terminalLabel = Label('Terminal Command: ')
        interpreterLabel = Label('Interpreter Command: ')

        self.c = Configuration()
        system = self.c.getSystem()

        runCommand = self.c.getRun(system)
        terminalCommand = self.c.getTerminal(system)
        interpreterCommand = self.c.getInterpreter(system)

        self.runBox = QLineEdit(runCommand)
        self.runBox.setCursorPosition(0)
        self.runBox.setMinimumWidth(30)
        self.terminalBox = QLineEdit(terminalCommand)
        self.terminalBox.setCursorPosition(0)
        self.interpreterBox = QLineEdit(interpreterCommand)
        self.interpreterBox.setCursorPosition(0)

        okButton = PushButton('OK')
        okButton.pressed.connect(self.close)

        groupBox1 = self.createRadioGroup()
        groupBox2 = self.createTextPadGroup()

        self.checkRadio(system)

        grid.addWidget(runLabel, 0, 0)
        grid.addWidget(self.runBox, 0, 1)
        grid.addWidget(terminalLabel, 1, 0)
        grid.addWidget(self.terminalBox, 1, 1)
        grid.addWidget(interpreterLabel, 2, 0)
        grid.addWidget(self.interpreterBox, 2, 1)
        grid.addWidget(okButton, 4, 1)
        grid.addWidget(groupBox1, 3, 0)
        grid.addWidget(groupBox2, 3, 1)

        self.setLayout(grid)

        self.show()
示例#10
0
 def init_ranked_list(self):
     # create labels and display them in a 1-column grid
     self.labels = [Label(str(i), self) for i in range(10)]
     for i in range(len(self.labels)):
         y = self.grid_y + i * self.row_height
         rank_label = QtGui.QLabel('%i' % i, self)
         rank_label.move(20, y)
     self.createGrid()
示例#11
0
 def __init__(self, widget, name='Widget', color='#ff999999'):
     if widget.width + 4 >= len(name) + 1:
         box = self.generate_box(widget.width + 2, widget.height + 2, color)
     else:
         box = self.generate_box(len(name), widget.height + 2, color)
     super().__init__(*box)
     self.add_child(widget, pos=(2, 2))
     self.add_child(Label(name, color='green'), pos=(1, 0))
     self._rebuild_self()
示例#12
0
 def _get_content(self):
     return Frame(
         VerticalLayout([
             SectionHeader(self.title),
             self.scrollable,
             Label("Directory:"),
             self.text_input,
             HorizontalLayout([
                 self.select_button, None, self.cancel_button
             ]),
         ], align=HALIGN_LEFT)
     )
示例#13
0
 def update_db(widg):
     final = widg.get()
     for child in frame.winfo_children():
         child.destroy()
     final = ValidatePlace(view, treebard, final)
     j = 0
     for dkt in final.place_dicts:
         lab = Label(frame,
                     text='{} id#{}'.format(final.place_dicts[j]["input"],
                                            final.place_dicts[j]["id"]))
         lab.grid()
         j += 1
示例#14
0
    def __init__(self, master, command, *args, **kwargs):
        Frame.__init__(self, master, *args, **kwargs)

        self.ent = Entry(self, width=36)
        spacer = Label(self, width=3)

        ok_butt = Button(self, text='OK', command=command)

        cancel_butt = Button(self, text='CANCEL', command=self.remove_edit_row)

        spacer.grid(column=0, row=0)
        self.ent.grid(column=1, row=0, padx=3, pady=3)
        ok_butt.grid(column=2, row=0, padx=6, pady=6)
        cancel_butt.grid(column=3, row=0, padx=6, pady=6)
示例#15
0
 def __init__(self, title, content):
     VerticalLayout.__init__(
         self,
         content=[
             HorizontalLayout([
                 Graphic(path=["titlebar", "left"], is_expandable=True),
                 Frame(Label(title, path=["titlebar"]),
                       path=["titlebar", "center"]),
                 Graphic(path=["titlebar", "right"], is_expandable=True),
             ],
                              align=VALIGN_BOTTOM,
                              padding=0),
             Frame(content, path=["titlebar", "frame"], is_expandable=True),
         ],
         padding=0)
示例#16
0
    def __init__(self, text="", window=None, batch=None, group=None,
                 theme=None, on_escape=None):
        def on_ok(dialog=None):
            if on_escape is not None:
                on_escape(self)
            self.teardown()

        return Dialog.__init__(self, content=Frame(
            VerticalLayout([
                Label(text),
                Button("Ok", on_click=on_ok),
            ])),
            window=window, batch=batch, group=group,
            theme=theme, movable=True,
            on_enter=on_ok, on_escape=on_ok)
示例#17
0
    def __init__(self, title, align=HALIGN_CENTER):
        if align == HALIGN_LEFT:
            left_expand = False
            right_expand = True
        elif align == HALIGN_CENTER:
            left_expand = True
            right_expand = True
        else:  # HALIGN_RIGHT
            left_expand = True
            right_expand = False

        HorizontalLayout.__init__(self,
                                  content=[
                                      Graphic(path=["section", "left"],
                                              is_expandable=left_expand),
                                      Frame(Label(title, path=["section"]),
                                            path=['section', 'center'],
                                            use_bg_group=True),
                                      Graphic(path=["section", "right"],
                                              is_expandable=right_expand),
                                  ],
                                  align=VALIGN_BOTTOM,
                                  padding=0)
示例#18
0
        height=450, 
        values=caseless_colors,
        scrollbar_size=16)

    Combobox.combobox_selected = combobox_selected

    flat2 = ButtonFlatHilited(canvas_0.content, text='Apply Combo 2')
    flat2.config(command=lambda button=flat2: colorize(button))

    b.grid(column=0, row=0, padx=6, pady=6)
    flat.grid(column=1, row=0, padx=6, pady=6)
    bb.grid(column=2, row=0, padx=6, pady=6)
    flat2.grid(column=3, row=0, padx=6, pady=6)
        
    frm = FrameStay(canvas_0.content)
    for i in range(10):
        lab = Label(frm, text=i)
        lab.grid(column=0, row=i+1, sticky='ew')

    msg = 'No valid\ncolor\nhas been\nchosen'
    cbox_select = Label(canvas_0.content, text=msg)

    frm.grid(column=0, row=1, sticky='news', columnspan=3)
    cbox_select.grid(column=3, row=1, sticky='news')

    CanvasScrolled.config_scrolled_canvases(main_app=root)

    root.mainloop()


示例#19
0
    def create_widgets(self):
        #Label((275,50,180,50), font=self.fonts[2], text=f"SCORE: {self.score}", bgcolor=BGCOLOR, fgcolor=BLACK).draw(self.screen)

        fonts = [
            pygame.font.SysFont('Arial', size, True) for size in (70, 40, 25)
        ]
        self.lose_label = Label(center=True,
                                size=(200, 100),
                                font=fonts[1],
                                text='You Lose',
                                fgcolor=BLACK)

        # Restart UI
        self.restartUI = Frame(pos=(45, 145),
                               size=(405, 405),
                               bgcolor=BLACK,
                               transparency=100)
        restart_lbl = Frame(parent=self.restartUI,
                            pos=(100, 100),
                            size=(205, 105),
                            bgcolor=(100, 100, 190))
        Label(parent=restart_lbl, center=True, font=fonts[1], text='Restart?')

        cancel_restart = Frame(parent=self.restartUI,
                               pos=(220, 215),
                               size=(75, 35),
                               bgcolor=(192, 100, 100))
        Button(parent=cancel_restart,
               center=True,
               font=fonts[1],
               text='No',
               command=lambda _: self.set_restart(False))

        do_restart = Frame(parent=self.restartUI,
                           pos=(115, 215),
                           size=(75, 35),
                           bgcolor=(192, 100, 100))
        Button(parent=do_restart,
               center=True,
               font=fonts[1],
               text='Yes',
               command=self.restart)

        # Main UI
        self.mainUI = Frame(pos=(0, 0),
                            size=(SCREENX, SCREENY),
                            bgcolor=BGCOLOR)

        undo_btn_image = Frame(parent=self.mainUI,
                               pos=(390, 95),
                               size=(50, 50),
                               image=pygame.image.load('undo.png'))
        Button(parent=undo_btn_image, command=self.undo)

        restart_btn_image = Frame(parent=self.mainUI,
                                  pos=(330, 95),
                                  size=(50, 50),
                                  image=pygame.image.load('restart.png'))
        Button(parent=restart_btn_image,
               command=lambda _: self.set_restart(True))

        title_frame = Frame(parent=self.mainUI, pos=(25, 50), size=(200, 80))
        Label(parent=title_frame, center=True, font=fonts[0], text="2048")

        score_frame = Frame(parent=self.mainUI, pos=(275, 50), size=(180, 50))
        self.score_label = Label(parent=score_frame,
                                 center=True,
                                 font=fonts[2],
                                 text='score')
示例#20
0
    def make_widgets(self):

        all_pics = self.get_all_pics()

        lab1 = Label(self, text='Gender:')
        self.gender_input = ClearableReadonlyCombobox(self, values=GENDER_TYPES)

        lab2 = Label(self, text='Main Image:')
        self.image_input = ClickAnywhereCombo(self, values=all_pics)

        lab3 = Label(self, text='Name Type:')
        self.name_type_input = ClearableReadonlyCombobox(self, values=self.get_name_types())

        lab4 = Label(self, text='Full Name')
        self.name_input = Entry(self, width=65)

        self.how = LabelH3(
            self, 
            text='Alphabetize name: after clicking auto-sort, tab into '
                  'auto-filled name fields to modify\nsort order with '
                  'arrow keys or if sort order is correct, just click ADD.')

        autosort = Button(
            self, text='AUTOSORT', command=self.show_sort_order)

        self.order_frm = Frame(self)

        s = 0
        for stg in range(20):
            mov = LabelMovable(self.order_frm)
            mov.grid(column=s, row=0, padx=3)
            s += 1 

        self.buttonbox = Frame(self)
        self.add_butt = Button(self.buttonbox, text='ADD', width=8)

        lab1.grid(column=0, row=3)
        self.gender_input.grid(
            column=1, row=3, padx=12, pady=12, sticky='e')
        lab2.grid(column=2, row=3)
        self.image_input.grid(column=3, row=3, padx=12, pady=12)
        lab3.grid(column=0, row=4)
        self.name_type_input.grid(
            column=1, row=4,  padx=12, pady=12, sticky='e')
        lab4.grid(column=2, row=4)
        self.name_input.grid(column=3, row=4, padx=12, pady=12)

        self.how.grid(column=0, row=5, padx=6, pady=6, columnspan=4)
        autosort.grid(column=0, row=6, padx=6, pady=6)
        self.order_frm.grid(column=1, row=6, columnspan=4, pady=24)
        self.buttonbox.grid(column=1, row=7, sticky='e')
        self.add_butt.grid(column=0, row=0, padx=6, pady=6, sticky='e')

        self.new_person_statusbar = StatusbarTooltips(self.parent, resizer=False)
        visited = (
            (self.gender_input, 
                "Gender Input", 
                "'Unknown' used if left blank."),
            (self.image_input, 
                "Image Input", 
                "Use an old photo of person's home town if no photo available."),
            (self.name_type_input, 
                "Name Type Input", 
                "Choose the name type."),
            (self.name_input, 
                "Name Input", 
                "Autofills but you can change it."),
            (autosort, 
                "Autosort Button", 
                "Click to auto-create a sortable name."),
            (self.order_frm, 
                "", 
                "Tab to focus name element. Arrow to change order.")
)        
        run_statusbar_tooltips(
            visited, 
            self.new_person_statusbar.status_label, 
            self.new_person_statusbar.tooltip_label)

        self.preset()

        rcm_widgets = (self.name_input, self.name_type_input)
        make_rc_menus(
            rcm_widgets, 
            self.rc_menu, 
            person_add_msg)
示例#21
0
                  values=color_strings,
                  scrollbar_size=16)
    # bb.config_values(short_list)

    flat = ButtonFlatHilited(canvas_0.content,
                             text='Flat Button',
                             command=colorize)

    b.grid(column=0, row=0, padx=6, pady=6)
    bb.grid(column=1, row=0, padx=6, pady=6)
    flat.grid(column=2, row=0, padx=6, pady=6)

    frm = FrameStay(canvas_0.content)
    frm.grid(column=0, row=1, sticky='news', columnspan=3)
    for i in range(10):
        lab = Label(frm, text=i)
        lab.grid(column=0, row=i + 1, sticky='ew')

    CanvasScrolled.config_scrolled_canvases(main_app=root)

    root.mainloop()

# DO LIST

# Bind entry to key press. if keypress is Up, highlight last item and scroll to it. If keypress is Down, highlight first item and scroll to it. Use code from other combobox. Keep focus in toplevel or canvas or content frame, not in buttons which don't take focus. Only arrows traverse buttons. If toplevel/canvas/content comes into focus, drop down. On focus out withdraw.
# test button bindings to Return, Space to work same as click
# Make flatbutton run the same code as selection
# make a virtual event that works like <<ComboboxSelected>> which can be bound to any callback
# The up OR down button should always open the dropdown whether it needs to fly up or fly down.
# Add code to make dropdown fly up if near bottom
# Make sure a focus_out event can be bound to the dropdown buttons or the content frame
示例#22
0
    def make_widgets(self):

        self.frm = Frame(self)
        self.frm.grid(column=0, row=0, pady=(0, 18))

        self.errlab = Label(self.frm, text='Input was: ')
        self.errlab.grid(column=0, row=0, padx=24, pady=(24, 0), sticky='w')
        self.errshow = LabelItalic(self.frm)
        self.errshow.grid(column=1, row=0, pady=(24, 0), sticky='w')

        self.errmsg = tk.Message(self.frm,
                                 text=self.message,
                                 bd=3,
                                 relief='raised',
                                 aspect=400)
        self.errmsg.grid(column=0, row=1, padx=36, pady=(0, 18), columnspan=2)

        self.promptlab = Label(self.frm)
        self.var = tk.StringVar()
        self.altentry = Entry(self.frm)
        self.altentry.config(textvariable=self.var)

        self.promptlab.grid(column=0, row=2, pady=24, padx=24, sticky='w')
        self.altentry.grid(column=1, row=2, pady=24, sticky='w')
        self.promptlab.grid_remove()
        self.altentry.grid_remove()

        self.altentry.focus_set()
        self.altentry.bind('<Return>', self.on_ok)

        self.bbox = Frame(self)
        self.bbox.grid(column=0, row=3, columnspan=2)

        self.done = Button(self.bbox, text='DONE', command=self.on_ok, width=9)
        self.done.grid(column=0, row=0, padx=24, pady=(12, 24))
        self.done.grid_remove()

        self.stop = Button(self.bbox,
                           text='CANCEL1',
                           command=self.on_cancel,
                           width=9)
        self.stop.grid(column=1, row=0, padx=24, pady=(12, 24))
        self.stop.grid_remove()

        self.done.focus_set()

        self.accept = Button(self.bbox,
                             text='Accept Original Input',
                             command=self.on_ok,
                             width=36)
        self.accept.grid(column=0, row=0, padx=24, pady=12)
        self.accept.grid_remove()

        self.edit = Button(self.bbox,
                           text='Submit Edited Input',
                           command=self.on_alt,
                           width=36)
        self.edit.grid(column=0, row=1, padx=24, pady=12)
        self.edit.grid_remove()

        self.cancel_all = Button(self.bbox,
                                 text="Cancel (Don't Submit Anything)",
                                 command=self.on_cancel,
                                 width=36)
        self.cancel_all.grid(column=0, row=2, padx=24, pady=(12, 36))
        self.cancel_all.grid_remove()

        self.bind('<Escape>', self.on_cancel)

        PlaySound('SystemHand', SND_ASYNC)

        self.protocol("WM_DELETE_WINDOW", self.on_cancel)
示例#23
0
import pygame, os
from pygame.locals import *
from constants import *
from widgets import Label

continueResults = True  # the variable returned to main.py; if False, close the results
savedText = None  # the text letting you know how many you saved
requiredText = None  # the text letting you know how many yoy needed to save
finalText = None  # the text letting you know your final result
clickText = Label(0, SCREEN_HEIGHT - 50,
                  "Click anywhere to go back to the main menu.")


def startResultsScreen(techMechsSaved, saveRequirement):
    global continueResults, savedText, requiredText, finalText

    continueResults = True
    savedText = Label(0, 0,
                      "You saved " + str(techMechsSaved) + " Tech Mechs.")
    requiredText = Label(0, 50,
                         "You needed " + str(saveRequirement) + " Tech Mechs.")
    if techMechsSaved >= saveRequirement:
        finalText = Label(0, 100, "Congratulations! You beat the level!")
    else:
        finalText = Label(0, 100, "Too bad! You didn't save enough.")


def handleResultsScreenEvents():
    global continueResults

    for event in pygame.event.get():
示例#24
0
    def make_widgets(self):
        def combobox_selected(combo):
            '''
                The reason this function is nested is that I have no experience 
                with overriding methods. When I tried to add `self` as the first 
                parameter, there was an error and I didn't know what to do. I 
                nested it so I wouldn't have to use `self`.
            '''
            if combo == self.combos["select_input_font"]:
                input_sample.config(font=(self.all_fonts[combo.current],
                                          self.fontSize))
            elif combo == self.combos["select_output_font"]:
                output_sample.config(font=(self.all_fonts[combo.current],
                                           self.fontSize))
            else:
                print("case not handled")
            # update_idletasks() seems to speed up the redrawing of the
            #   app with the new font
            self.update_idletasks()

        sample_text = ["Sample", "Text ABCDEFGHxyz 0123456789 iIl1 o0O"]

        self.columnconfigure(0, weight=1)
        self.rowconfigure(0, weight=1)

        sample = Frame(self)

        self.output_sample = Label(sample, text=" Output ".join(sample_text))

        self.input_sample = Entry(sample, width=50)
        self.input_sample.insert(0, " Input ".join(sample_text))

        self.fontSizeVar = tk.IntVar()
        self.fontSize = self.font_scheme[0]

        self.font_size = Scale(
            self,
            from_=8.0,
            to=26.0,
            tickinterval=6.0,
            label="Text Size",  # Can this be centered over the Scale?
            orient="horizontal",
            length=200,
            variable=self.fontSizeVar,
            command=self.show_font_size)
        self.font_size.set(self.fontSize)

        combo_names = ["select_output_font", "select_input_font"]
        self.combos = {}

        j = 2
        for name in combo_names:
            cbo = Combobox(self,
                           self.root,
                           values=self.all_fonts,
                           height=300,
                           scrollbar_size=12)
            self.combos[name] = cbo
            name = name.replace("_", " ").title()
            lab = Label(self, text=name)
            lab.grid(column=0, row=j, pady=(24, 6))
            cbo.grid(column=0, row=j + 1, pady=(6, 20))
            j += 2

        self.apply_button = Button(self, text="APPLY", command=self.apply)

        sample.grid(column=0, row=0)
        self.output_sample.grid(padx=24, pady=20)
        self.input_sample.grid(padx=24, pady=20)
        self.font_size.grid(column=0, row=1, pady=24)
        self.apply_button.grid(column=0,
                               row=7,
                               sticky="e",
                               padx=(0, 24),
                               pady=(0, 24))

        Combobox.combobox_selected = combobox_selected
示例#25
0
        conn.execute('PRAGMA foreign_keys = 1')
        cur = conn.cursor()
        cur.execute(update_format_fonts, tuple(self.font_scheme))
        conn.commit()
        cur.close()
        conn.close()

        config_generic(self.root)

        resize_scrollbar()

    def show_font_size(self, evt):
        self.fontSize = self.fontSizeVar.get()


if __name__ == "__main__":

    root = tk.Tk()

    t = FontPicker(root, root)
    t.grid()

    q = Label(
        root,
        text="This text represents everything outside of the "
        "font picker.\n It doesn't change until you click the APPLY button.")
    q.grid(padx=24, pady=48)

    config_generic(root)

    root.mainloop()
示例#26
0
    def show_choices(self):
        conn = sqlite3.connect(current_file)
        cur = conn.cursor()

        self.radvars = []
        for dd in self.place_dicts:
            self.var = tk.IntVar(None, 0)
            self.radvars.append(self.var)

        d = 0
        t = 0
        bullet = len(self.place_dicts)
        # configure place_id for query
        for dkt in self.place_dicts:
            add_new_place_option = False
            place_hints = []
            if len(dkt["id"]) == 1:
                if dkt.get("temp_id") is None:
                    place_id = (dkt["id"][0], )
                else:
                    place_id = (dkt["id"][0])
                    add_new_place_option = True
            elif len(dkt["id"]) > 1:
                if dkt.get("temp_id") is not None:
                    add_new_place_option = True
                place_id = dkt["id"]
            elif dkt.get("temp_id") is None:
                place_id = ("none", )
            elif dkt.get("temp_id"):
                # place id will be int type which marks it as a new place
                place_id = dkt["temp_id"]
            else:
                print("line", looky(seeline()).lineno, "case not handled")
            if type(place_id) is int:
                place_hints.append('')
            else:
                for num in place_id:
                    if num == "none":
                        place_hints.append('')
                    else:
                        cur.execute(select_place_hint, (num, ))
                        place_hint = cur.fetchone()
                        if place_hint[0] is None:
                            place_hint = ''
                        else:
                            place_hint = place_hint[0]
                        place_hints.append(place_hint)
            # reconfigure place_id for display
            if type(place_id) is int:
                if dkt["temp_id"] is not None and len(dkt["id"]) > 0:
                    place_hints.append('')
            elif add_new_place_option is True:
                place_hints.append('')
            elif len(place_id) == 1:
                place_id = place_id[0]
            else:
                print("line", looky(seeline()).lineno, "case not handled")
            place_input = dkt["input"]
            place_string = '{}: {}, place ID #{}'.format(
                bullet, place_input, place_id)

            lab = Label(self.frm, text=place_string)
            lab.grid(column=0, row=d, sticky='w')

            self.hint_frm = Frame(self.frm, name="nest{}".format(bullet - 1))
            self.hint_frm.grid(column=0,
                               row=d + 1,
                               sticky='w',
                               padx=(0, 3),
                               columnspan=2)
            self.hint_frm.columnconfigure(0, minsize=48)

            self.make_edit_row(self.hint_frm)

            h = 0
            row = 0
            for hint in place_hints:
                if dkt.get("temp_id") is not None and len(dkt["id"]) > 0:
                    # user will choose between a new ID or one of the existing IDs
                    new_id = dkt["temp_id"]
                    last_idx = len(dkt["id"])
                    if h == last_idx:
                        current_id = new_id
                        rad_string = "{}: {} (new place and new place ID)".format(
                            current_id, dkt["input"])
                    else:
                        current_id = dkt["id"][h]
                        cur.execute(select_first_nested_place, (current_id, ))
                        nesting = cur.fetchone()
                        nesting = [i for i in nesting if i]
                        nesting = ", ".join(nesting)
                        rad_string = "{}: {}".format(current_id, nesting)
                elif dkt.get("temp_id") is not None and len(dkt["id"]) == 0:
                    # user will OK or CANCEL new ID
                    current_id = dkt["temp_id"]
                    rad_string = "{}: {} (new place and new place ID)".format(
                        current_id, dkt["input"])
                else:
                    current_id = dkt["id"][h]
                    cur.execute(select_first_nested_place, (current_id, ))
                    nesting = cur.fetchone()
                    nesting = [i for i in nesting if i]
                    nesting = ", ".join(nesting)
                    rad_string = "{}: {}".format(current_id, nesting)
                rad = RadiobuttonBig(self.hint_frm,
                                     variable=self.radvars[t],
                                     value=h,
                                     text=rad_string,
                                     anchor="w")
                lab = Label(self.hint_frm,
                            text="hint: {}".format(hint),
                            anchor='w',
                            bg='red')
                editx = ButtonQuiet(
                    self.hint_frm,
                    width=2,
                    command=lambda hint=hint: self.grid_edit_row(hint))

                self.hint_frm.columnconfigure(1, weight=1)
                rad.grid(column=0, row=row, sticky='we', columnspan=2)
                editx.grid(column=0, row=row + 1, pady=(0, 3), sticky='e')
                lab.grid(column=1, row=row + 1, sticky='w', padx=6)

                editx.bind('<Enter>', self.on_hover)
                editx.bind('<Leave>', self.on_unhover)
                editx.bind('<Button-1>', self.get_clicked_row)
                editx.bind('<space>', self.get_clicked_row)
                editx.bind('<FocusIn>', self.on_hover)
                editx.bind('<FocusOut>', self.on_unhover)
                h += 1
                row += 2

            sep = Separator(self.frm, 3)
            sep.grid(column=0,
                     row=d + 2,
                     sticky='ew',
                     columnspan=3,
                     pady=(3, 0))
            d += 3
            t += 1
            bullet -= 1

        cur.close()
        conn.close()
示例#27
0
    def make_widgets(self):

        stripview = Frame(self.parent)
        stripview.grid(column=0, row=0, padx=12, pady=12)

        self.parent.update_idletasks()
        self.colors_canvas = Canvas(
            stripview, 
            bd=1, highlightthickness=1, 
            highlightbackground=formats['highlight_bg'], 
            bg=formats['bg'],
            width=840,
            height=118
) 
        hscroll = Scrollbar(
            stripview, orient='horizontal', command=self.colors_canvas.xview)
        self.colors_canvas.configure(xscrollcommand=hscroll.set)
        
        self.colors_canvas.grid(column=0, row=0, sticky='news')
        hscroll.grid(column=0, row=1, sticky="ew")

        self.colors_content = Frame(self.colors_canvas)

        bbox1 = Frame(self.parent)
        bbox1.grid(column=0, row=1, padx=12, pady=12, sticky='we')
        bbox1.columnconfigure(1, weight=1)
        bbox1.rowconfigure(1, weight=1)

        self.try_button = Button(
            bbox1, text='TRY', width=7, command=self.config_local)
        self.try_button.grid(column=0, row=0, sticky='w')

        self.copy_button = Button(
            bbox1, text='COPY', width=7, command=self.copy_scheme)
        self.copy_button.grid(column=1, row=0)

        self.apply_button = Button(
            bbox1, text='APPLY', width=7, command=self.apply_scheme)
        self.apply_button.grid(column=2, row=0, sticky='e')

        bottom = Frame(self.parent)
        bottom.grid(column=0, row=2, padx=12, pady=12)

        addlab = LabelH3(bottom, text='New Color Scheme')
        addlab.grid(column=0, row=0, padx=6, pady=6, columnspan=2)

        self.colors_table = Frame(bottom)
        self.colors_table.grid(column=0, row=1, columnspan=2)
        self.colors_table.columnconfigure(0, weight=1)
        self.colors_table.rowconfigure(0, weight=1)

        all_schemes = get_color_schemes()

        self.h1 = Label(
            self.colors_table,
            anchor='w', 
            text=' Domain',
            font=formats['output_font'])

        self.h2 = Label(
            self.colors_table,
            anchor='w',
            text=' Color')

        opening_colors = (
            formats['bg'], 
            formats['highlight_bg'], 
            formats['head_bg'], 
            formats['fg'])

        displabel = self.make_colors_table(opening_colors)

        bbox2 = Frame(bottom)
        bbox2.grid(
            column=0, row=2, 
            padx=12, pady=12, 
            sticky='ew', columnspan=2)
        bbox2.columnconfigure(1, weight=1)
        bbox2.rowconfigure(0, weight=1)

        self.new_button = Button(
            bbox2, 
            text='CREATE NEW COLOR SAMPLE', 
            command=self.make_new_sample)
        self.new_button.grid(column=0, row=0, padx=6, pady=6, columnspan=2)

        self.make_samples()

        self.colors_canvas.create_window(
            0, 0, anchor='nw', window=self.colors_content)
        self.resize_color_samples_scrollbar()
示例#28
0
    def make_widgets(self):

        if self.parent.winfo_class() == 'Toplevel':
            gallery_canvas = Canvas(
                self.parent,
                bd=0,
                highlightthickness=0)

            self.gallery_content = Frame(gallery_canvas)
            gallery_canvas.grid(row=0, column=0, sticky='nsew')

            self.parent.grid_columnconfigure(0, weight=1)
            self.parent.grid_rowconfigure(0, weight=1)
        else:
            self.gallery_content = Frame(self.parent)
            self.gallery_content.grid(column=0, row=0)

        self.thumb_canvas = Canvas(
            self.gallery_content, 
            bd=0, 
            highlightthickness=0,
            bg=formats['bg'])
        self.thumb_canvas.pack(padx=12, pady=12)

        self.thumbstrip = Frame(self.thumb_canvas)
        self.thumbstrip.pack(side='top')

        self.previous_img = Button(self.gallery_content, text='<<', width=6)

        self.pic_canvas = Canvas(
            self.gallery_content, 
            highlightbackground=formats['bg'])
        self.pic_canvas.bind('<Button-1>', self.focus_clicked)
        self.pic_canvas.bind('<Button-1>', self.scroll_start, add='+')
        self.pic_canvas.bind('<B1-Motion>', self.scroll_move)     

        self.img_path = '{}treebard_gps\data\{}\images\{}'.format(
            root_drive, self.image_dir, self.main_pic)
        img_big = Image.open(self.img_path)
        self.tk_img = ImageTk.PhotoImage(img_big)
        self.pic_canvas.image = self.tk_img

        z = 0
        self.current_pictures = sorted(self.current_pictures)

        for img in self.current_pictures:
            pic_col = Frame(self.thumbstrip)
            pic_col.pack(side='left', expand=1, fill='y')

            pic_file = img
            self.img_path = '{}treebard_gps\data\{}\images\{}'.format(root_drive, self.image_dir, pic_file)
            idx = len(pic_file)
            bare = pic_file[0:idx-4]
            thumbsy = Image.open(self.img_path)
            self.width_strings.append(thumbsy.width)
            self.height_strings.append(thumbsy.height)
            thumbsy.thumbnail((185,85))
            thumb_path = 'images/{}_tmb.png'.format(bare)
            # overwrites file by same name if it exists 
            thumbsy.save(thumb_path)
            small = ImageTk.PhotoImage(file=thumb_path, master=self.thumbstrip)

            thumb = Label(
                pic_col,
                image=small)
            thumb.pack(expand=1, fill='y')
            thumb.image = small

            self.thumb_labels.append(thumb)

            # lambda used to save value in loop
            if self.parent.winfo_class() == 'Toplevel':
                rad = Radiobutton(
                    pic_col,
                    takefocus=0,
                    value=pic_file,
                    command=lambda pic_file=pic_file: self.set_main_pic(
                        pic_file))   
                rad.pack()

                if rad['value'] == self.main_pic:
                    rad.select()

            else:                
                rad = Frame(
                    pic_col,
                    height=24,
                    width=24)   
                rad.pack(expand=1, fill='both')
                if self.parent.winfo_name() == 'source_tab':
                    pic_file = '{}, {}'.format(self.source, pic_file)
            
            create_tooltip(rad, pic_file)

            z += 1

        self.pil_img = img_big
        self.fit_canvas_to_pic()

        self.thumb_dict = dict(zip(self.thumb_labels, self.current_pictures))
        self.next_img = Button(self.gallery_content, text='>>', width=6)

        panel = Frame(self.gallery_content)

        subject = LabelH3(panel, text=self.curr_entity)
        subject.grid(column=0, row=0, sticky='ew')

        # labels with selectable multiline text
        self.caption_lab = MessageCopiable(panel, width=36)
        self.picfile_lab = MessageCopiable(panel, width=36)
        self.picsize_lab = MessageCopiable(panel, width=36)
        edit = Button(
            panel, 
            text='EDIT', 
            width=8, 
            command=lambda graphics=self.t7: self.go_to_graphics(graphics))

        self.previous_img.config(command=self.back)
        self.next_img.config(command=self.forward)

        panel.grid_rowconfigure(0, weight=2)
        panel.grid_rowconfigure(1, weight=1)
        panel.grid_rowconfigure(4, weight=2)

        self.caption_lab.grid(column=0, row=1, pady=(12,12), sticky='ew')
        self.caption_lab.insert(1.0, self.caption_text)

        self.picfile_lab.grid(column=0, row=2, pady=(12,0), sticky='ew')
        self.picfile_lab.insert(1.0, self.img_path)

        self.picsize_lab.grid(column=0, row=3, pady=(0,24), sticky='ew')
        self.picsize_lab.insert(
            1.0, 
            'width: {}, height: {}'.format(
                self.pil_img.width, self.pil_img.height))

        edit.grid(column=0, row=4)

        self.caption_lab.set_height()
        self.picfile_lab.set_height()
        self.picsize_lab.set_height()

        self.previous_img.pack(side='left', padx=12)
        self.pic_canvas.pack(side='left', expand=1, fill='y')
        self.next_img.pack(side='left', padx=12)

        panel.pack(side='left', expand=1, fill='y')

        for thumb in self.thumb_labels:
            thumb.bind('<Button-1>', self.show_clicked)

        self.pic_canvas.bind('<Key-Left>', lambda evt: self.back())

        self.pic_canvas.bind('<Key-Right>', lambda evt: self.forward())

        # add statusbar-tooltips

        self.visited = (
            (self.thumbstrip, 
                "Thumbnail Views", 
                "Click thumbnail to display. Hover below to see "
                   "file name. If radio, click to make main image."),
            (self.pic_canvas, 
                "Image", 
                "Arrow keys change image when it's in focus."),
            (self.previous_img, 
                "Left Button", 
                "Click with mouse or when highlighted click with spacebar."),
            (self.next_img, 
                "Right Button", 
                "Click with mouse or when highlighted click with spacebar.")) 

        if self.parent.winfo_class() == 'Toplevel':
     
            box = Frame(self.parent)
            box.grid(column=0, row=1, pady=12)

            close = Button(
                box, 
                text='CLOSE', 
                width=8, 
                command=self.cancel_gallery)  
            close.grid()
            self.parent.protocol('WM_DELETE_WINDOW', self.cancel_gallery)

        self.thumb_canvas.create_window(0, 0, anchor='nw', window=self.thumbstrip)
        self.thumb_canvas.config(
            scrollregion=(
                0, 0, 
                self.thumbstrip.winfo_reqwidth(), 
                self.thumbstrip.winfo_reqheight()))
        
        self.thumb_canvas.config(
            width=self.root.maxsize()[0], 
            height=self.thumbstrip.winfo_reqheight())
        
        scroll_width = int(self.thumb_canvas['scrollregion'].split(' ')[2])

        if scroll_width >= int(self.thumb_canvas['width']):
            for child in self.thumbstrip.winfo_children():
                for gchild in child.winfo_children():
                    gchild.bind("<Enter>", self.thumb_start)
                    gchild.bind("<Motion>", self.thumb_move)

        if self.parent.winfo_class() == 'Toplevel':

            gallery_canvas.create_window(
                0, 0, anchor=tk.NW, window=self.gallery_content)
            self.resize_scrollbar()
            self.resize_window()

        self.config_labels()
示例#29
0
 def build(self):
     self.panel.pack((5, 5))
     self.label = Label(self.panel, self.label)
     self.panel.pack(self.label, fill=True)
     self.progressbar = ProgressBar(self.panel)
     self.panel.pack(self.progressbar, fill=True, padding=15)
示例#30
0
    def make_widgets(self):

        self.title('{}{} ({})'.format('Notes for Conclusion #',
                                      self.finding_id, self.birth_name))

        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(1, weight=1)
        header = Frame(self)
        header.grid_columnconfigure(1, weight=1)
        header.grid_rowconfigure(0, weight=1)

        self.notes_dialog_header = Frame(header)

        content = Frame(self)

        left_panel = Frame(content)

        topiclab = Label(left_panel, text='Note Subtopics')

        self.toc = Listbox(left_panel,
                           self.sorted_subtopics,
                           view_height=424,
                           view_width=180,
                           scrollbar=False)

        self.new_index = len(self.subtopics)
        self.toc.insert(self.new_index, self.new_subtopic_label_text)
        self.toc.focus_set()
        self.toc.selection_set(0)

        self.toc.store_new_subtopic_name = self.store_new_subtopic_name
        self.toc.pass_ctrl_click = self.open_links_dialog
        self.toc.pass_delete_key = self.delete_note

        self.selected_subtopic = Label(content, text='New Note')

        self.note_input = ScrolledText(content)

        note_submit = Button(content,
                             text='Submit Changes',
                             command=self.save_changes)

        order = Button(content,
                       text='Change Order of Subtopics',
                       command=self.reorder_notes)

        radframe = LabelFrame(content, text='Make selected note...')

        self.public = Radiobutton(radframe,
                                  text='...public',
                                  anchor='w',
                                  variable=self.privacy,
                                  value=0,
                                  command=self.save_privacy_setting)

        self.private = Radiobutton(radframe,
                                   text='...private',
                                   anchor='w',
                                   variable=self.privacy,
                                   value=1,
                                   command=self.save_privacy_setting)

        close = Button(content, text='DONE', command=self.close_roles_dialog)

        # notes_statusbar = StatusbarTooltips(self)

        # visited = (
        # (above,
        # 'this is a notes_statusbar message',
        # 'this is a tooltip'),
        # (below,
        # 'this is also a notes_statusbar message',
        # 'this is another tooltip'))

        # run_statusbar_tooltips(
        # visited,
        # notes_statusbar.status_label,
        # notes_statusbar.tooltip_label)

        # grid in self
        header.grid(column=0, row=0, columnspan=2, pady=12, sticky='we')
        content.grid(column=0, row=1, sticky='news', padx=(0, 6))
        # notes_statusbar.grid(column=0, row=2, sticky='ew')

        # grid in header
        self.notes_dialog_header.grid(column=1, row=0, sticky='ew')
        self.notes_dialog_header.grid_columnconfigure(0, weight=1)

        # grid in content
        left_panel.grid(column=0, row=1, sticky='news', rowspan=2, pady=24)
        self.selected_subtopic.grid(column=1, row=1, sticky='w')
        self.note_input.grid(column=1,
                             row=2,
                             columnspan=3,
                             sticky='nsew',
                             padx=(0, 24),
                             pady=12)
        note_submit.grid(column=3, row=3, sticky='se')
        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)
        content.grid_rowconfigure(1, weight=1)
        order.grid(column=1, row=4)
        radframe.grid(column=2, row=5, sticky='n', pady=24)
        close.grid(column=3, row=6, sticky='se', padx=24, pady=(0, 24))

        # grid in left_panel
        topiclab.grid(column=0, row=0)
        self.toc.grid(column=0, row=1)
        for child in self.toc.listbox_content.winfo_children():
            child.bind('<<ListboxSelected>>', self.switch_note)

        self.subtopic_widgets = self.toc.listbox_content.winfo_children()

        # grid in radframe
        self.public.grid(column=0, row=0, sticky='news', padx=24)
        self.private.grid(column=0, row=1, sticky='news', padx=24)

        # rcm_widgets = (self.subtopic_input, self.note_input.text)
        # make_rc_menus(
        # rcm_widgets,
        # self.rc_menu,
        # note_dlg_msg,
        # header_parent=self.notes_dialog_header,
        # header=self.header,
        # which_dlg='notes')

        config_generic(self)
        center_window(self)