Example #1
0
    def __init__(self):
        style = ttk.Style("cosmo")
        self._root = style.master
        self._root.title("FBSerial")
        self._root.resizable(False, False)
        # self._root.attributes("-topmost", True)
        self._root.protocol("WM_DELETE_WINDOW", self.shutdown)

        frame = ttk.LabelFrame(self._root, text="串口选择")
        frame.pack(padx=5, pady=5)
        self._portsCombo = ttk.Combobox(frame, state="readonly", width=23)
        self._portsCombo.pack(side="left", padx=5, pady=5)

        self._conButton = ttk.Button(frame, text="连接", command=self._connect)
        self._refreshButton = ttk.Button(frame,
                                         text="刷新",
                                         command=self._getPorts)
        self._conButton.pack(side="left", padx=5, pady=5)
        self._refreshButton.pack(side="left", padx=5, pady=5)

        self._prePort = None
        self._connected = False

        self._ser = FBSerial()
        self._ser.registerConnectCallback(self._conCB)
        self._ser.registerDisconnectCallback(self._disconCB)
Example #2
0
    def setup_theme_creator(self):
        # application menu
        self.menu = ttk.Menu()
        self.menu.add_command(label="Save", command=self.save_theme)
        self.menu.add_command(label="Reset", command=self.change_base_theme)
        self.menu.add_command(label="Import", command=self.import_user_themes)
        self.menu.add_command(label="Export", command=self.export_user_themes)
        self.configure(menu=self.menu)

        # theme configuration settings
        ## user theme name
        f1 = ttk.Frame(self.configure_frame, padding=(5, 2))
        ttk.Label(f1, text="name", width=12).pack(side=LEFT)
        self.theme_name = ttk.Entry(f1)
        self.theme_name.insert(END, "new theme")
        self.theme_name.pack(side=LEFT, fill=X, expand=YES)
        f1.pack(fill=X, expand=YES)

        ## base theme
        f2 = ttk.Frame(self.configure_frame, padding=(5, 2))
        ttk.Label(f2, text="base theme", width=12).pack(side=LEFT)
        self.base_theme = ttk.Combobox(f2, values=self.style.theme_names())
        self.base_theme.insert(END, "litera")
        self.base_theme.pack(side=LEFT, fill=X, expand=YES)
        f2.pack(fill=X, expand=YES, pady=(0, 15))
        self.base_theme.bind("<<ComboboxSelected>>", self.change_base_theme)

        ## color options
        self.color_rows = []
        for color in self.style.colors.label_iter():
            row = ColorRow(self.configure_frame, color, self.style)
            self.color_rows.append(row)
            row.pack(fill=BOTH, expand=YES)
            row.bind("<<ColorSelected>>", self.create_temp_theme)
def create_combobox_test(bootstyle, style, test_name):
    frame = ttk.Frame(padding=10)

    # title
    title = ttk.Label(
        master=frame, 
        text=test_name, 
        anchor=tk.CENTER
    )
    title.pack(padx=5, pady=2, fill=tk.BOTH)
    ttk.Separator(frame).pack(padx=5, pady=5, fill=tk.X)

    # default
    cbo = ttk.Combobox(
        master=frame, 
        values=['default', 'other'], 
        bootstyle=bootstyle
    )
    cbo.pack(padx=5, pady=5, fill=tk.BOTH)
    cbo.current(0)

    # color
    for color in style.theme.colors:
        cbo = ttk.Combobox(
            master=frame, 
            values=[color, 'other'], 
            bootstyle=(color, bootstyle)
        )
        cbo.pack(padx=5, pady=5, fill=tk.BOTH)
        cbo.current(0)

    # disabled
    cbo = ttk.Combobox(
        master=frame, 
        values=[bootstyle,'other'], 
        bootstyle=bootstyle, 
        state=tk.DISABLED
    )
    cbo.pack(padx=5, pady=5, fill=tk.BOTH)
    cbo.current(0)

    return frame
Example #4
0
    def __init__(self, master):
        super().__init__(master)
        self.pack(fill=BOTH, expand=YES)

        self.images = [
            PhotoImage(name='reset',
                       file=PATH / 'magic_mouse/icons8_reset_24px.png'),
            PhotoImage(name='reset-small',
                       file=PATH / 'magic_mouse/icons8_reset_16px.png'),
            PhotoImage(name='submit',
                       file=PATH /
                       'magic_mouse/icons8_submit_progress_24px.png'),
            PhotoImage(name='question',
                       file=PATH /
                       'magic_mouse/icons8_question_mark_16px.png'),
            PhotoImage(name='direction',
                       file=PATH / 'magic_mouse/icons8_move_16px.png'),
            PhotoImage(name='bluetooth',
                       file=PATH / 'magic_mouse/icons8_bluetooth_2_16px.png'),
            PhotoImage(name='buy',
                       file=PATH / 'magic_mouse/icons8_buy_26px_2.png'),
            PhotoImage(name='mouse', file=PATH / 'magic_mouse/magic_mouse.png')
        ]

        for i in range(3):
            self.columnconfigure(i, weight=1)
        self.rowconfigure(0, weight=1)

        # column 1
        col1 = ttk.Frame(self, padding=10)
        col1.grid(row=0, column=0, sticky=NSEW)

        # device info
        dev_info = ttk.Labelframe(col1, text='Device Info', padding=10)
        dev_info.pack(side=TOP, fill=BOTH, expand=YES)

        # header
        dev_info_header = ttk.Frame(dev_info, padding=5)
        dev_info_header.pack(fill=X)

        btn = ttk.Button(master=dev_info_header,
                         image='reset',
                         bootstyle=LINK,
                         command=self.callback)
        btn.pack(side=LEFT)

        lbl = ttk.Label(dev_info_header, text='Model 2009, 2xAA Batteries')
        lbl.pack(side=LEFT, fill=X, padx=15)

        btn = ttk.Button(master=dev_info_header,
                         image='submit',
                         bootstyle=LINK,
                         command=self.callback)
        btn.pack(side=LEFT)

        # image
        ttk.Label(dev_info, image='mouse').pack(fill=X)

        # progressbar
        pb = ttk.Progressbar(dev_info, value=66)
        pb.pack(fill=X, pady=5, padx=5)
        ttk.Label(pb, text='66%', bootstyle=(PRIMARY, INVERSE)).pack()

        # progress message
        self.setvar('progress', 'Battery is discharging.')
        lbl = ttk.Label(master=dev_info,
                        textvariable='progress',
                        font='Helvetica 8',
                        anchor=CENTER)
        lbl.pack(fill=X)

        # licence info
        lic_info = ttk.Labelframe(col1, text='License Info', padding=20)
        lic_info.pack(side=TOP, fill=BOTH, expand=YES, pady=(10, 0))
        lic_info.rowconfigure(0, weight=1)
        lic_info.columnconfigure(0, weight=2)

        lic_title = ttk.Label(master=lic_info,
                              text='Trial Version, 28 days left',
                              anchor=CENTER)
        lic_title.pack(fill=X, pady=(0, 20))

        lbl = ttk.Label(master=lic_info,
                        text='Mouse serial number:',
                        anchor=CENTER,
                        font='Helvetica 8')
        lbl.pack(fill=X)
        self.setvar('license', 'dtMM2-XYZGHIJKLMN3')

        lic_num = ttk.Label(master=lic_info,
                            textvariable='license',
                            bootstyle=PRIMARY,
                            anchor=CENTER)
        lic_num.pack(fill=X, pady=(0, 20))

        buy_now = ttk.Button(master=lic_info,
                             image='buy',
                             text='Buy now',
                             compound=BOTTOM,
                             command=self.callback)
        buy_now.pack(padx=10, fill=X)

        # Column 2
        col2 = ttk.Frame(self, padding=10)
        col2.grid(row=0, column=1, sticky=NSEW)

        # scrolling
        scrolling = ttk.Labelframe(col2, text='Scrolling', padding=(15, 10))
        scrolling.pack(side=TOP, fill=BOTH, expand=YES)

        op1 = ttk.Checkbutton(scrolling, text='Scrolling', variable='op1')
        op1.pack(fill=X, pady=5)

        # no horizontal scrolling
        op2 = ttk.Checkbutton(master=scrolling,
                              text='No horizontal scrolling',
                              variable='op2')
        op2.pack(fill=X, padx=(20, 0), pady=5)

        btn = ttk.Button(master=op2,
                         image='question',
                         bootstyle=LINK,
                         command=self.callback)
        btn.pack(side=RIGHT)

        # inverse
        op3 = ttk.Checkbutton(master=scrolling,
                              text='Inverse scroll directcion vertically',
                              variable='op3')
        op3.pack(fill=X, padx=(20, 0), pady=5)

        btn = ttk.Button(master=op3,
                         image='direction',
                         bootstyle=LINK,
                         command=self.callback)
        btn.pack(side=RIGHT)

        # Scroll only vertical or horizontal
        op4 = ttk.Checkbutton(master=scrolling,
                              text='Scroll only vertical or horizontal',
                              state=DISABLED)
        op4.configure(variable='op4')
        op4.pack(fill=X, padx=(20, 0), pady=5)

        # smooth scrolling
        op5 = ttk.Checkbutton(master=scrolling,
                              text='Smooth scrolling',
                              variable='op5')
        op5.pack(fill=X, padx=(20, 0), pady=5)

        btn = ttk.Button(master=op5,
                         image='bluetooth',
                         bootstyle=LINK,
                         command=self.callback)
        btn.pack(side=RIGHT)

        # scroll speed
        scroll_speed_frame = ttk.Frame(scrolling)
        scroll_speed_frame.pack(fill=X, padx=(20, 0), pady=5)

        lbl = ttk.Label(scroll_speed_frame, text='Speed:')
        lbl.pack(side=LEFT)

        scale = ttk.Scale(scroll_speed_frame, value=35, from_=1, to=100)
        scale.pack(side=LEFT, fill=X, expand=YES, padx=5)

        scroll_speed_btn = ttk.Button(master=scroll_speed_frame,
                                      image='reset-small',
                                      bootstyle=LINK,
                                      command=self.callback)
        scroll_speed_btn.pack(side=LEFT)

        # scroll sense
        scroll_sense_frame = ttk.Frame(scrolling)
        scroll_sense_frame.pack(fill=X, padx=(20, 0), pady=(5, 0))

        ttk.Label(scroll_sense_frame, text='Sense:').pack(side=LEFT)

        scale = ttk.Scale(scroll_sense_frame, value=50, from_=1, to=100)
        scale.pack(side=LEFT, fill=X, expand=YES, padx=5)

        scroll_sense_btn = ttk.Button(master=scroll_sense_frame,
                                      image='reset-small',
                                      bootstyle=LINK,
                                      command=self.callback)
        scroll_sense_btn.pack(side=LEFT)

        # 1 finger gestures
        finger_gest = ttk.Labelframe(master=col2,
                                     text='1 Finger Gestures',
                                     padding=(15, 10))
        finger_gest.pack(side=TOP, fill=BOTH, expand=YES, pady=(10, 0))
        op6 = ttk.Checkbutton(master=finger_gest,
                              text='Fast swipe left/right',
                              variable='op6')
        op6.pack(fill=X, pady=5)

        cb = ttk.Checkbutton(master=finger_gest,
                             text='Swap swipe direction',
                             variable='op7')
        cb.pack(fill=X, padx=(20, 0), pady=5)

        # gest sense
        gest_sense_frame = ttk.Frame(finger_gest)
        gest_sense_frame.pack(fill=X, padx=(20, 0), pady=(5, 0))

        ttk.Label(gest_sense_frame, text='Sense:').pack(side=LEFT)

        scale = ttk.Scale(gest_sense_frame, value=50, from_=1, to=100)
        scale.pack(side=LEFT, fill=X, expand=YES, padx=5)

        btn = ttk.Button(master=gest_sense_frame,
                         image='reset-small',
                         bootstyle=LINK,
                         command=self.callback)
        btn.pack(side=LEFT)

        # middle click
        middle_click = ttk.Labelframe(master=col2,
                                      text='Middle Click',
                                      padding=(15, 10))
        middle_click.pack(side=TOP, fill=BOTH, expand=YES, pady=(10, 0))
        cbo = ttk.Combobox(master=middle_click,
                           values=['Any 2 finger', 'Other 1', 'Other 2'])
        cbo.current(0)
        cbo.pack(fill=X)

        # Column 3
        col3 = ttk.Frame(self, padding=10)
        col3.grid(row=0, column=2, sticky=NSEW)

        # two finger gestures
        two_finger_gest = ttk.Labelframe(master=col3,
                                         text='2 Finger Gestures',
                                         padding=10)
        two_finger_gest.pack(side=TOP, fill=BOTH)

        op7 = ttk.Checkbutton(master=two_finger_gest,
                              text='Fast swipe left/right',
                              variable='op7')
        op7.pack(fill=X, pady=5)

        op8 = ttk.Checkbutton(master=two_finger_gest,
                              text='Swap swipe direction',
                              variable='op8')
        op8.pack(fill=X, padx=(20, 0), pady=5)

        # gest sense
        gest_sense_frame = ttk.Frame(two_finger_gest)
        gest_sense_frame.pack(fill=X, padx=(20, 0), pady=(5, 0))

        ttk.Label(gest_sense_frame, text='Sense:').pack(side=LEFT)

        scale = ttk.Scale(gest_sense_frame, value=50, from_=1, to=100)
        scale.pack(side=LEFT, fill=X, expand=YES, padx=5)

        btn = ttk.Button(master=gest_sense_frame,
                         image='reset-small',
                         bootstyle=LINK,
                         command=self.callback)
        btn.pack(side=LEFT)

        # fast two finger swipe down
        lbl = ttk.Label(master=two_finger_gest,
                        text='On fast 2 finger up/down swipe:')
        lbl.pack(fill=X, pady=(10, 5))

        op9 = ttk.Checkbutton(master=two_finger_gest,
                              text='Swap swipe direction',
                              variable='op9')
        op9.pack(fill=X, padx=(20, 0), pady=5)

        op10 = ttk.Checkbutton(master=two_finger_gest,
                               text='Swap swipe direction',
                               variable='op10')
        op10.pack(fill=X, padx=(20, 0), pady=5)

        two_finger_cbo = ttk.Combobox(
            master=two_finger_gest,
            values=['Cycle Task View | Normal | Desktop View'])
        two_finger_cbo.current(0)
        two_finger_cbo.pack(fill=X, padx=(20, 0), pady=5)

        # two finger sense
        two_finger_sense_frame = ttk.Frame(two_finger_gest)
        two_finger_sense_frame.pack(fill=X, padx=(20, 0), pady=(5, 0))

        ttk.Label(two_finger_sense_frame, text='Sense:').pack(side=LEFT)

        scale = ttk.Scale(two_finger_sense_frame, value=50, from_=1, to=100)
        scale.pack(side=LEFT, fill=X, expand=YES, padx=5)

        two_finger_sense_btn = ttk.Button(master=two_finger_sense_frame,
                                          image='reset-small',
                                          bootstyle=LINK)
        two_finger_sense_btn.configure(command=self.callback)
        two_finger_sense_btn.pack(side=LEFT)

        # mouse options
        mouse_options = ttk.Labelframe(master=col3,
                                       text='2 Finger Gestures',
                                       padding=(15, 10))
        mouse_options.pack(side=TOP, fill=BOTH, expand=YES, pady=(10, 0))

        op11 = ttk.Checkbutton(master=mouse_options,
                               text='Ignore input if mouse if lifted',
                               variable='op11')
        op11.pack(fill=X, pady=5)

        op12 = ttk.Checkbutton(master=mouse_options,
                               text='Ignore input if mouse if lifted',
                               variable='op12')
        op12.pack(fill=X, pady=5)

        op13 = ttk.Checkbutton(master=mouse_options,
                               text='Ignore input if mouse if lifted',
                               variable='op13')
        op13.pack(fill=X, pady=5)

        # base speed
        base_speed_sense_frame = ttk.Frame(mouse_options)
        base_speed_sense_frame.pack(fill=X, padx=(20, 0), pady=(5, 0))

        lbl = ttk.Label(base_speed_sense_frame, text='Base speed:')
        lbl.pack(side=LEFT)

        scale = ttk.Scale(base_speed_sense_frame, value=50, from_=1, to=100)
        scale.pack(side=LEFT, fill=X, expand=YES, padx=5)

        base_speed_sense_btn = ttk.Button(master=base_speed_sense_frame,
                                          image='reset-small',
                                          bootstyle=LINK)
        base_speed_sense_btn.configure(command=self.callback)
        base_speed_sense_btn.pack(side=LEFT)

        # turn on all checkbuttons
        for i in range(1, 14):
            self.setvar(f'op{i}', 1)

        # turn off select buttons
        for j in [2, 9, 12, 13]:
            self.setvar(f'op{j}', 0)
Example #5
0
def setup_demo(master):

    ZEN = """Beautiful is better than ugly. 
Explicit is better than implicit. 
Simple is better than complex. 
Complex is better than complicated.
Flat is better than nested. 
Sparse is better than dense.  
Readability counts.
Special cases aren't special enough to break the rules.
Although practicality beats purity.
Errors should never pass silently.
Unless explicitly silenced.
In the face of ambiguity, refuse the temptation to guess.
There should be one-- and preferably only one --obvious way to do it.
Although that way may not be obvious at first unless you're Dutch.
Now is better than never.
Although never is often better than *right* now.
If the implementation is hard to explain, it's a bad idea.
If the implementation is easy to explain, it may be a good idea.
Namespaces are one honking great idea -- let's do more of those!"""

    root = ttk.Frame(master, padding=10)
    style = ttk.Style()
    theme_names = style.theme_names()

    theme_selection = ttk.Frame(root, padding=(10, 10, 10, 0))
    theme_selection.pack(fill=X, expand=YES)

    theme_selected = ttk.Label(master=theme_selection,
                               text="litera",
                               font="-size 24 -weight bold")
    theme_selected.pack(side=LEFT)

    lbl = ttk.Label(theme_selection, text="Select a theme:")
    theme_cbo = ttk.Combobox(
        master=theme_selection,
        text=style.theme.name,
        values=theme_names,
    )
    theme_cbo.pack(padx=10, side=RIGHT)
    theme_cbo.current(theme_names.index(style.theme.name))
    lbl.pack(side=RIGHT)

    ttk.Separator(root).pack(fill=X, pady=10, padx=10)

    def change_theme(e):
        t = cbo.get()
        style.theme_use(t)
        theme_selected.configure(text=t)
        theme_cbo.selection_clear()
        default.focus_set()

    theme_cbo.bind("<<ComboboxSelected>>", change_theme)

    lframe = ttk.Frame(root, padding=5)
    lframe.pack(side=LEFT, fill=BOTH, expand=YES)

    rframe = ttk.Frame(root, padding=5)
    rframe.pack(side=RIGHT, fill=BOTH, expand=YES)

    color_group = ttk.Labelframe(master=lframe,
                                 text="Theme color options",
                                 padding=10)
    color_group.pack(fill=X, side=TOP)

    for color in style.colors:
        cb = ttk.Button(color_group, text=color, bootstyle=color)
        cb.pack(side=LEFT, expand=YES, padx=5, fill=X)

    rb_group = ttk.Labelframe(lframe,
                              text="Checkbuttons & radiobuttons",
                              padding=10)
    rb_group.pack(fill=X, pady=10, side=TOP)

    check1 = ttk.Checkbutton(rb_group, text="selected")
    check1.pack(side=LEFT, expand=YES, padx=5)
    check1.invoke()

    check2 = ttk.Checkbutton(rb_group, text="alternate")
    check2.pack(side=LEFT, expand=YES, padx=5)

    check4 = ttk.Checkbutton(rb_group, text="deselected")
    check4.pack(side=LEFT, expand=YES, padx=5)
    check4.invoke()
    check4.invoke()

    check3 = ttk.Checkbutton(rb_group, text="disabled", state=DISABLED)
    check3.pack(side=LEFT, expand=YES, padx=5)

    radio1 = ttk.Radiobutton(rb_group, text="selected", value=1)
    radio1.pack(side=LEFT, expand=YES, padx=5)
    radio1.invoke()

    radio2 = ttk.Radiobutton(rb_group, text="deselected", value=2)
    radio2.pack(side=LEFT, expand=YES, padx=5)

    radio3 = ttk.Radiobutton(master=rb_group,
                             text="disabled",
                             value=3,
                             state=DISABLED)
    radio3.pack(side=LEFT, expand=YES, padx=5)

    ttframe = ttk.Frame(lframe)
    ttframe.pack(pady=5, fill=X, side=TOP)

    table_data = [
        ("South Island, New Zealand", 1),
        ("Paris", 2),
        ("Bora Bora", 3),
        ("Maui", 4),
        ("Tahiti", 5),
    ]

    tv = ttk.Treeview(master=ttframe, columns=[0, 1], show=HEADINGS, height=5)
    for row in table_data:
        tv.insert("", END, values=row)

    tv.selection_set("I001")
    tv.heading(0, text="City")
    tv.heading(1, text="Rank")
    tv.column(0, width=300)
    tv.column(1, width=70, anchor=CENTER)
    tv.pack(side=LEFT, anchor=NE, fill=X)

    # # notebook with table and text tabs
    nb = ttk.Notebook(ttframe)
    nb.pack(side=LEFT, padx=(10, 0), expand=YES, fill=BOTH)
    nb_text = "This is a notebook tab.\nYou can put any widget you want here."
    nb.add(ttk.Label(nb, text=nb_text), text="Tab 1", sticky=NW)
    nb.add(child=ttk.Label(nb, text="A notebook tab."),
           text="Tab 2",
           sticky=NW)
    nb.add(ttk.Frame(nb), text="Tab 3")
    nb.add(ttk.Frame(nb), text="Tab 4")
    nb.add(ttk.Frame(nb), text="Tab 5")

    # text widget
    txt = ScrolledText(master=lframe, height=5, width=50, autohide=True)
    txt.insert(END, ZEN)
    txt.pack(side=LEFT, anchor=NW, pady=5, fill=BOTH, expand=YES)
    lframe_inner = ttk.Frame(lframe)
    lframe_inner.pack(fill=BOTH, expand=YES, padx=10)
    s1 = ttk.Scale(master=lframe_inner,
                   orient=HORIZONTAL,
                   value=75,
                   from_=100,
                   to=0)
    s1.pack(fill=X, pady=5, expand=YES)

    ttk.Progressbar(
        master=lframe_inner,
        orient=HORIZONTAL,
        value=50,
    ).pack(fill=X, pady=5, expand=YES)

    ttk.Progressbar(
        master=lframe_inner,
        orient=HORIZONTAL,
        value=75,
        bootstyle=(SUCCESS, STRIPED),
    ).pack(fill=X, pady=5, expand=YES)

    m = ttk.Meter(
        master=lframe_inner,
        metersize=150,
        amountused=45,
        subtext="meter widget",
        bootstyle=INFO,
        interactive=True,
    )
    m.pack(pady=10)

    sb = ttk.Scrollbar(
        master=lframe_inner,
        orient=HORIZONTAL,
    )
    sb.set(0.1, 0.9)
    sb.pack(fill=X, pady=5, expand=YES)

    sb = ttk.Scrollbar(master=lframe_inner,
                       orient=HORIZONTAL,
                       bootstyle=(DANGER, ROUND))
    sb.set(0.1, 0.9)
    sb.pack(fill=X, pady=5, expand=YES)

    btn_group = ttk.Labelframe(master=rframe, text="Buttons", padding=(10, 5))
    btn_group.pack(fill=X)

    menu = ttk.Menu(root)
    for i, t in enumerate(style.theme_names()):
        menu.add_radiobutton(label=t, value=i)

    default = ttk.Button(master=btn_group, text="solid button")
    default.pack(fill=X, pady=5)
    default.focus_set()

    mb = ttk.Menubutton(
        master=btn_group,
        text="solid menubutton",
        bootstyle=SECONDARY,
        menu=menu,
    )
    mb.pack(fill=X, pady=5)

    cb = ttk.Checkbutton(
        master=btn_group,
        text="solid toolbutton",
        bootstyle=(SUCCESS, TOOLBUTTON),
    )
    cb.invoke()
    cb.pack(fill=X, pady=5)

    ob = ttk.Button(
        master=btn_group,
        text="outline button",
        bootstyle=(INFO, OUTLINE),
        command=lambda: Messagebox.ok("You pushed an outline button"),
    )
    ob.pack(fill=X, pady=5)

    mb = ttk.Menubutton(
        master=btn_group,
        text="outline menubutton",
        bootstyle=(WARNING, OUTLINE),
        menu=menu,
    )
    mb.pack(fill=X, pady=5)

    cb = ttk.Checkbutton(
        master=btn_group,
        text="outline toolbutton",
        bootstyle=(SUCCESS, OUTLINE, TOOLBUTTON),
    )
    cb.pack(fill=X, pady=5)

    lb = ttk.Button(master=btn_group, text="link button", bootstyle=LINK)
    lb.pack(fill=X, pady=5)

    cb1 = ttk.Checkbutton(
        master=btn_group,
        text="rounded toggle",
        bootstyle=(SUCCESS, ROUND, TOGGLE),
    )
    cb1.invoke()
    cb1.pack(fill=X, pady=5)

    cb2 = ttk.Checkbutton(master=btn_group,
                          text="squared toggle",
                          bootstyle=(SQUARE, TOGGLE))
    cb2.pack(fill=X, pady=5)
    cb2.invoke()

    input_group = ttk.Labelframe(master=rframe,
                                 text="Other input widgets",
                                 padding=10)
    input_group.pack(fill=BOTH, pady=(10, 5), expand=YES)
    entry = ttk.Entry(input_group)
    entry.pack(fill=X)
    entry.insert(END, "entry widget")

    password = ttk.Entry(master=input_group, show="•")
    password.pack(fill=X, pady=5)
    password.insert(END, "password")

    spinbox = ttk.Spinbox(master=input_group, from_=0, to=100)
    spinbox.pack(fill=X)
    spinbox.set(45)

    cbo = ttk.Combobox(
        master=input_group,
        text=style.theme.name,
        values=theme_names,
        exportselection=False,
    )
    cbo.pack(fill=X, pady=5)
    cbo.current(theme_names.index(style.theme.name))

    de = ttk.DateEntry(input_group)
    de.pack(fill=X)

    return root
Example #6
0
    def create_right_frame(self):
        container = ttk.Frame(self)
        container.pack(side=RIGHT, fill=BOTH, expand=YES, padx=5)

        # demonstrates various button styles
        btn_group = ttk.Labelframe(master=container,
                                   text="Buttons",
                                   padding=(10, 5))
        btn_group.pack(fill=X)

        menu = ttk.Menu(self)
        for i, t in enumerate(self.style.theme_names()):
            menu.add_radiobutton(label=t, value=i)

        default = ttk.Button(master=btn_group, text="solid button")
        default.pack(fill=X, pady=5)
        default.focus_set()

        mb = ttk.Menubutton(
            master=btn_group,
            text="solid menubutton",
            bootstyle=SECONDARY,
            menu=menu,
        )
        mb.pack(fill=X, pady=5)

        cb = ttk.Checkbutton(
            master=btn_group,
            text="solid toolbutton",
            bootstyle=(SUCCESS, TOOLBUTTON),
        )
        cb.invoke()
        cb.pack(fill=X, pady=5)

        ob = ttk.Button(master=btn_group,
                        text="outline button",
                        bootstyle=(INFO, OUTLINE))
        ob.pack(fill=X, pady=5)

        mb = ttk.Menubutton(
            master=btn_group,
            text="outline menubutton",
            bootstyle=(WARNING, OUTLINE),
            menu=menu,
        )
        mb.pack(fill=X, pady=5)

        cb = ttk.Checkbutton(
            master=btn_group,
            text="outline toolbutton",
            bootstyle="success-outline-toolbutton",
        )
        cb.pack(fill=X, pady=5)

        lb = ttk.Button(master=btn_group, text="link button", bootstyle=LINK)
        lb.pack(fill=X, pady=5)

        cb1 = ttk.Checkbutton(
            master=btn_group,
            text="rounded toggle",
            bootstyle=(SUCCESS, ROUND, TOGGLE),
        )
        cb1.invoke()
        cb1.pack(fill=X, pady=5)

        cb2 = ttk.Checkbutton(master=btn_group,
                              text="squared toggle",
                              bootstyle=(SQUARE, TOGGLE))
        cb2.pack(fill=X, pady=5)
        cb2.invoke()

        input_group = ttk.Labelframe(master=container,
                                     text="Other input widgets",
                                     padding=10)
        input_group.pack(fill=BOTH, pady=(10, 5), expand=YES)
        entry = ttk.Entry(input_group)
        entry.pack(fill=X)
        entry.insert(END, "entry widget")

        password = ttk.Entry(master=input_group, show="•")
        password.pack(fill=X, pady=5)
        password.insert(END, "password")

        spinbox = ttk.Spinbox(master=input_group, from_=0, to=100)
        spinbox.pack(fill=X)
        spinbox.set(45)

        cbo = ttk.Combobox(
            master=input_group,
            text=self.style.theme.name,
            values=self.style.theme_names(),
        )
        cbo.pack(fill=X, pady=5)
        cbo.current(self.style.theme_names().index(self.style.theme.name))

        de = ttk.DateEntry(input_group)
        de.pack(fill=X)
Example #7
0
    def __init__(self,
                 master=None,
                 is_vertical=True,
                 queue_size: int = 10,
                 **kw):
        super().__init__(master, **kw)
        self._recv = FBFloatRecv(queue_size=queue_size)
        self.input = self._recv.input
        self.registerRecvCallback = self._recv.registerRecvCallback
        self.start = self._recv.start

        idLabel = ttk.Label(self, text="ID")
        self._idCbo = ttk.Combobox(self,
                                   width=4,
                                   state="readonly",
                                   values=["无"] + list(range(256)))
        self._idCbo.current(0)
        self._idCbo.bind("<<ComboboxSelected>>", self._applyID)

        cntLabel = ttk.Label(self, text="个数")
        self._cntEntry = ValEntry(lambda s: s.isdigit() and int(s) > 0,
                                  self,
                                  width=5)

        bitsLabel = ttk.Label(self, text="位数")
        self._bitsCbo = ttk.Combobox(self,
                                     width=4,
                                     state="readonly",
                                     values=[4, 8])
        self._bitsCbo.current(0)

        checkLabel = ttk.Label(self, text="校验")
        self._checkCbo = ttk.Combobox(self,
                                      width=4,
                                      state="readonly",
                                      values=["sum", "none"])
        self._checkCbo.current(0)

        extra = self.extraBody(self)

        self._cbs: callable = []
        applyButton = ttk.Button(self, text="应用", command=self._clickCB)

        if is_vertical:
            idLabel.grid(row=0, column=0, sticky="w")
            self._idCbo.grid(row=0, column=1, sticky="w")
            cntLabel.grid(row=1, column=0, sticky="w")
            self._cntEntry.grid(row=1, column=1, sticky="we")
            bitsLabel.grid(row=2, column=0, sticky="w")
            self._bitsCbo.grid(row=2, column=1, sticky="we")
            checkLabel.grid(row=3, column=0, sticky="w")
            self._checkCbo.grid(row=3, column=1, sticky="we")
            if extra is not None:
                extra.grid(row=4, column=0, columnspan=2, sticky="we")
            applyButton.grid(row=4 + (extra is not None),
                             column=0,
                             columnspan=2,
                             sticky="we")
        else:
            idLabel.pack(side="left")
            self._idCbo.pack(side="left", padx=2)
            cntLabel.pack(side="left")
            self._cntEntry.pack(side="left", padx=2)
            bitsLabel.pack(side="left")
            self._bitsCbo.pack(side="left", padx=2)
            checkLabel.pack(side="left")
            self._checkCbo.pack(side="left", padx=2)
            if extra is not None:
                extra.pack(side="left")
            applyButton.pack(side="left", padx=2)

        self.loadConfig()
Example #8
0
root = tk.Tk()
style = ttk.Style()

frame = ttk.Frame(padding=5)
frame.pack(padx=5, pady=5, fill=tk.X)

frame1 = ttk.Frame(frame)
frame2 = ttk.Frame(frame)
frame3 = ttk.Frame(frame)
frame1.pack(fill=tk.X)
frame2.pack(fill=tk.X)
frame3.pack(fill=tk.X)

for i, color in enumerate(['default', *style.colors]):
    if i < 5:
        a = ttk.Combobox(frame1, bootstyle=color, width=12)
    else:
        a = ttk.Combobox(frame2, bootstyle=color, width=12)
    a.insert('end', color)
    a.pack(side=tk.LEFT, padx=3, pady=10)

# disabled
a = ttk.Combobox(frame3, width=12)
a.insert(tk.END, 'disabled')
a.pack(side=tk.LEFT, padx=3, pady=10)
a.configure(state=tk.DISABLED)

# readonly
a = ttk.Combobox(frame3, width=12)
a.insert(tk.END, 'readonly')
a.pack(side=tk.LEFT, padx=3, pady=10)