Ejemplo n.º 1
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)
Ejemplo n.º 2
0
def create_entry_test(style):
    frame = ttk.Frame(padding=10)

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

    # default
    ttk.Label(frame, text='default').pack()
    entry = ttk.DateEntry(frame)
    entry.pack(padx=5, pady=5, fill=tk.BOTH)

    # color
    for color in style.theme.colors:
        ttk.Label(frame, text=color).pack()
        entry = ttk.DateEntry(frame, bootstyle=color)
        entry.pack(padx=5, pady=5, fill=tk.BOTH)

    ttk.Label(frame, text='disabled').pack()
    entry = ttk.DateEntry(frame)
    entry.configure(state=tk.DISABLED)
    entry.pack(padx=5, pady=5, fill=tk.BOTH)

    ttk.Label(frame, text='readonly').pack()
    entry = ttk.DateEntry(frame)
    entry.configure(state='readonly')
    entry.pack(padx=5, pady=5, fill=tk.BOTH)

    return frame
Ejemplo n.º 3
0
    def create_band(self, master, text):
        """Create and pack an equalizer band"""
        value = randint(1, 99)
        self.setvar(text, value)

        container = ttk.Frame(master)
        container.pack(side=LEFT, fill=Y, padx=10)

        # header label
        hdr = ttk.Label(container, text=text, anchor=CENTER)
        hdr.pack(side=TOP, fill=X, pady=10)

        # volume scale
        if text in ["VOL", "GAIN"]:
            bootstyle = SUCCESS
        else:
            bootstyle = INFO

        scale = ttk.Scale(
            master=container,
            orient=VERTICAL,
            from_=99,
            to=1,
            value=value,
            command=lambda x=value, y=text: self.update_value(x, y),
            bootstyle=bootstyle,
        )
        scale.pack(fill=Y)

        # value label
        val = ttk.Label(master=container, textvariable=text)
        val.pack(pady=10)
Ejemplo n.º 4
0
def create_scale_frame(widget_style, style, orient):
    frame = ttk.Frame(root, padding=5)

    # title
    title = ttk.Label(frame, text=orient.title() + ' Scale', anchor=tk.CENTER)
    title.pack(padx=5, pady=2, fill=tk.BOTH)
    ttk.Separator(frame).pack(padx=5, pady=5, fill=tk.X)

    # default
    pb = ttk.Scale(master=frame, orient=orient, value=0.2)
    if orient == tk.HORIZONTAL:
        pb.pack(padx=5, pady=5, fill=tk.BOTH)
    else:
        pb.pack(padx=5, pady=5, fill=tk.BOTH, side=tk.LEFT)

    # colored
    for color in style.colors:
        ttk.Label(frame, text=color).pack(fill=tk.X)
        pb = ttk.Scale(master=frame, value=0.2, bootstyle=color, orient=orient)
        if orient == tk.HORIZONTAL:
            pb.pack(padx=5, pady=5, fill=tk.BOTH)
        else:
            pb.pack(padx=5, pady=5, fill=tk.BOTH, side=tk.LEFT)

    return frame
Ejemplo n.º 5
0
def create_separator_frame(widget_style, style, orient):
    frame = ttk.Frame(root, padding=5)

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

    # default
    sep = ttk.Separator(frame, orient=orient)
    if orient == tk.HORIZONTAL:
        sep.pack(padx=5, pady=5, fill=tk.BOTH)
    else:
        sep.pack(padx=5, pady=5, fill=tk.BOTH, side=tk.LEFT)

    # colored
    for i, color in enumerate(style.colors):
        ttk.Label(frame, text=color).pack(fill=tk.X)
        sep = ttk.Separator(master=frame, bootstyle=color, orient=orient)
        if orient == tk.HORIZONTAL:
            sep.pack(padx=5, pady=5, fill=tk.BOTH)
        else:
            sep.pack(padx=5, pady=5, fill=tk.BOTH, side=tk.LEFT)

    return frame
Ejemplo n.º 6
0
    def body(self, master):
        master.pack_configure(fill="x", expand=True)
        master.grid_columnconfigure(1, weight=1)
        WIDTH = 100

        ttk.Label(master, text="名称").grid(row=0, column=0)
        self.nameEntry = ttk.Entry(master, width=WIDTH)
        self.nameEntry.grid(row=0, column=1, sticky="ew")

        ttk.Label(master, text="指令").grid(row=1, column=0)
        self.cmdEntry = ttk.Entry(master, width=WIDTH)
        self.cmdEntry.grid(row=1, column=1, sticky="ew")

        ttk.Label(master, text="变量").grid(row=2, column=0)
        self.varEntry = ttk.Entry(master, width=WIDTH)
        self.varEntry.grid(row=2, column=1, sticky="ew")

        ttk.Label(master, text="绑定").grid(row=3, column=0)
        self.bindEntry = ttk.Entry(master, width=WIDTH)
        self.bindEntry.grid(row=3, column=1, sticky="ew")

        for i, entry in enumerate(
            (self.nameEntry, self.cmdEntry, self.varEntry, self.bindEntry)):
            entry.insert("end", self.default[i])

        f = (self.nameEntry, self.cmdEntry, self.varEntry,
             self.bindEntry)[self.focus]
        f.select_range(0, "end")
        return f
Ejemplo n.º 7
0
    def create_progress_meter(self):
        """Create frame with progress meter with lables"""
        container = ttk.Frame(self)
        container.pack(fill=X, expand=YES, pady=10)

        self.elapse = ttk.Label(container, text='00:00')
        self.elapse.pack(side=LEFT, padx=10)

        self.scale = ttk.Scale(master=container,
                               command=self.on_progress,
                               bootstyle=SECONDARY)
        self.scale.pack(side=LEFT, fill=X, expand=YES)

        self.remain = ttk.Label(container, text='03:10')
        self.remain.pack(side=LEFT, fill=X, padx=10)
Ejemplo n.º 8
0
def create_entry_test(bootstyle, style):
    frame = ttk.Frame(padding=10)

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

    # default
    entry = ttk.Entry(frame, bootstyle=bootstyle)
    entry.pack(padx=5, pady=5, fill=tk.BOTH)
    entry.insert(tk.END, 'default')

    # color
    for color in style.theme.colors:
        entry = ttk.Entry(frame, bootstyle=color)
        entry.pack(padx=5, pady=5, fill=tk.BOTH)
        entry.insert(tk.END, color)

    # readonly
    entry = ttk.Entry(frame, bootstyle=bootstyle)
    entry.insert(tk.END, 'readonly')
    entry.configure(state=READONLY)
    entry.pack(padx=5, pady=5, fill=tk.BOTH)

    # disabled
    entry = ttk.Entry(frame, bootstyle=bootstyle)
    entry.insert(tk.END, 'disabled')
    entry.configure(state=DISABLED)
    entry.pack(padx=5, pady=5, fill=tk.BOTH)

    return frame
Ejemplo n.º 9
0
def create_labelframe_style(bootstyle, style):
    frame = ttk.Frame(root, padding=5)

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

    # default
    lbl = ttk.Labelframe(master=frame,
                         text='default',
                         bootstyle=bootstyle,
                         width=150,
                         height=75)
    lbl.pack(padx=5, pady=5, fill=tk.BOTH)

    # colored
    for color in style.colors:
        lbl = ttk.Labelframe(master=frame,
                             text=color,
                             bootstyle=color,
                             width=150,
                             height=75)
        lbl.pack(padx=5, pady=5, fill=tk.BOTH)

    return frame
Ejemplo n.º 10
0
def button_style_frame(bootstyle, style, widget_name):
    frame = ttk.Frame(root, padding=5)

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

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

    ttk.Button(
        master=frame,
        text='default',
        bootstyle=bootstyle
    ).pack(padx=5, pady=5)

    for color in style.colors:
        ttk.Button(
            master=frame,
            text=color,
            bootstyle=f'{color}-{bootstyle}'
        ).pack(padx=5, pady=5)

    ttk.Button(
        master=frame,
        text='disabled',
        state=tk.DISABLED,
        bootstyle=bootstyle
    ).pack(padx=5, pady=5)

    return frame
Ejemplo n.º 11
0
 def construct(self, frame: ttk.Frame) -> None:
     self.data.setdefault("text", tk.StringVar())
     self.label = ttk.Label(frame, text=self.name)
     self.entry = ttk.Entry(frame, textvariable=self.data["text"])
     self.entry.bind("<Return>", lambda _: self._callback("enter"))
     self.label.pack(side="left")
     self.entry.pack(side="left")
Ejemplo n.º 12
0
    def create_buttonbox(self, master):
        frame = ttk.Frame(master, padding=(5, 5))

        # OK button
        ok = ttk.Button(frame,
                        bootstyle=PRIMARY,
                        width=6,
                        text=MessageCatalog.translate('OK'))
        ok.bind("<Return>", lambda _: ok.invoke())
        ok.configure(command=lambda b=ok: self.on_button_press(b))
        ok.pack(padx=2, side=RIGHT)

        # Cancel button
        cancel = ttk.Button(frame,
                            bootstyle=SECONDARY,
                            width=6,
                            text=MessageCatalog.translate('Cancel'))
        cancel.bind("<Return>", lambda _: cancel.invoke())
        cancel.configure(command=lambda b=cancel: self.on_button_press(b))
        cancel.pack(padx=2, side=RIGHT)

        # color dropper (not supported on Mac OS)
        if self._toplevel.winsys != 'aqua':
            dropper = ttk.Label(frame, text=PEN, font=('-size 16'))
            ToolTip(dropper,
                    MessageCatalog.translate('color dropper'))  # add tooltip
            dropper.pack(side=RIGHT, padx=2)
            dropper.bind("<Button-1>", self.on_show_colordropper)

        frame.pack(side=BOTTOM, fill=X, anchor=S)
Ejemplo n.º 13
0
def create_checkbutton_test(bootstyle, style, name):
    frame = ttk.Frame(padding=10)

    # title
    title = ttk.Label(frame, text=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 style
    cb = ttk.Checkbutton(frame, text='default', bootstyle=bootstyle)
    cb.pack(padx=5, pady=5, fill=tk.BOTH)
    cb.invoke()

    # color styles
    for color in style.theme.colors:
        cb = ttk.Checkbutton(
            master=frame, 
            text=color, 
            bootstyle=color + bootstyle,
            width=15
        )
        cb.pack(padx=5, pady=5, fill=tk.BOTH)
        cb.invoke()

    # disabled style
    cb = ttk.Checkbutton(
        master=frame, 
        text='disabled', 
        bootstyle=bootstyle,
        state=tk.DISABLED
    )
    cb.pack(padx=5, pady=5, fill=tk.BOTH)
    cb.invoke()

    return frame
Ejemplo n.º 14
0
    def create_type_row(self):
        """Add type row to labelframe"""
        type_row = ttk.Frame(self.option_lf)
        type_row.pack(fill=X, expand=YES)
        type_lbl = ttk.Label(type_row, text="Type", width=8)
        type_lbl.pack(side=LEFT, padx=(15, 0))

        contains_opt = ttk.Radiobutton(master=type_row,
                                       text="Contains",
                                       variable=self.type_var,
                                       value="contains")
        contains_opt.pack(side=LEFT)

        startswith_opt = ttk.Radiobutton(master=type_row,
                                         text="StartsWith",
                                         variable=self.type_var,
                                         value="startswith")
        startswith_opt.pack(side=LEFT, padx=15)

        endswith_opt = ttk.Radiobutton(master=type_row,
                                       text="EndsWith",
                                       variable=self.type_var,
                                       value="endswith")
        endswith_opt.pack(side=LEFT)
        endswith_opt.invoke()
Ejemplo n.º 15
0
    def __init__(self, master, color, style):
        super().__init__(master, padding=(5, 2))
        self.colorname = color
        self.style = style

        self.label = ttk.Label(self, text=color, width=12)
        self.label.pack(side=LEFT)
        self.patch = Frame(master=self,
                           background=self.style.colors.get(color),
                           width=15)
        self.patch.pack(side=LEFT, fill=BOTH, padx=2)
        self.entry = ttk.Entry(self, width=12)
        self.entry.pack(side=LEFT, fill=X, expand=YES)
        self.entry.bind("<FocusOut>", self.enter_color)
        self.color_picker = ttk.Button(
            master=self,
            text="...",
            bootstyle=SECONDARY,
            command=self.pick_color,
        )
        self.color_picker.pack(side=LEFT, padx=2)

        # set initial color value and patch color
        self.color_value = self.style.colors.get(color)
        self.update_patch_color()
Ejemplo n.º 16
0
def create_spinbox_test(bootstyle, style):
    frame = ttk.Frame(padding=10)

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

    # default
    spinbox = ttk.Spinbox(frame)
    spinbox.pack(padx=5, pady=5, fill=tk.BOTH)
    spinbox.insert(tk.END, 'default')

    # color
    for color in style.theme.colors:
        spinbox = ttk.Spinbox(frame, bootstyle=color)
        spinbox.pack(padx=5, pady=5, fill=tk.BOTH)
        spinbox.insert(tk.END, color)

    # disabled
    spinbox = ttk.Spinbox(frame)
    spinbox.insert(tk.END, 'disabled')
    spinbox.configure(state=tk.DISABLED)
    spinbox.pack(padx=5, pady=5, fill=tk.BOTH)

    # readonly
    spinbox = ttk.Spinbox(frame)
    spinbox.insert(tk.END, 'readonly')
    spinbox.configure(state='readonly')
    spinbox.pack(padx=5, pady=5, fill=tk.BOTH)

    return frame
Ejemplo n.º 17
0
 def create_header(self):
     """The application header to display user messages"""
     self.hdr_var.set("Open a file to begin playback")
     lbl = ttk.Label(master=self,
                     textvariable=self.hdr_var,
                     bootstyle=(LIGHT, INVERSE),
                     padding=10)
     lbl.pack(fill=X, expand=YES)
Ejemplo n.º 18
0
    def __init__(self) -> None:
        style = ttk.Style("cosmo")
        self._root = style.master
        self._root.title("FBMapDraw - 左键删除 右键添加")
        self._root.rowconfigure(0, weight=1)
        self._root.columnconfigure(0, weight=1)

        self._plotFrame = ttk.Frame(self._root)
        self._plotFrame.grid(row=0, column=0, sticky="wesn")
        self._plotFrame.rowconfigure(0, weight=1)
        self._plotFrame.columnconfigure(0, weight=1)
        self._fig = plt.Figure()
        self._setA4Size()
        self._canvas = FigureCanvasTkAgg(self._fig, master=self._plotFrame)
        self._canvas.get_tk_widget().grid(row=0, column=0, sticky="wesn")
        self._ax = self._fig.add_subplot(1, 1, 1)
        self._ax.set_picker(True)
        self._ax.set_aspect("equal")
        self._canvas.mpl_connect("pick_event", self._onPick)

        self._opFrame = ttk.Frame(self._root)
        self._opFrame.grid(row=1, column=0, sticky="we")
        self._clearButton = ttk.Button(self._opFrame,
                                       text="清空",
                                       command=self.clear)
        self._saveButton = ttk.Button(self._opFrame,
                                      text="保存",
                                      command=self.save)
        self._loadButton = ttk.Button(self._opFrame,
                                      text="读取",
                                      command=self.load)
        self._clearButton.pack(side="left", padx=5, pady=5)
        self._saveButton.pack(side="left", padx=5, pady=5)
        self._loadButton.pack(side="left", padx=5, pady=5)

        ttk.Label(
            self._opFrame,
            text=f"保存路径: {os.path.join(SAVE_DIR, SAVE_NAME_TXT)}\t点数: ").pack(
                side="left", pady=5)

        self.pointCnt = tk.IntVar(self._root, value=0)
        ttk.Label(self._opFrame, textvariable=self.pointCnt).pack(side="left",
                                                                  pady=5)

        self.circles = {}
Ejemplo n.º 19
0
def create_label_style(bootstyle, style, test_name):
    frame = ttk.Frame(root, padding=5)

    # title
    title = ttk.Label(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
    lbl = ttk.Label(frame, text='default', bootstyle=bootstyle)
    lbl.pack(padx=5, pady=5, fill=tk.BOTH)

    # colored
    for color in style.colors:
        lbl = ttk.Label(frame, text=color, bootstyle=(color, bootstyle))
        lbl.pack(padx=5, pady=5, fill=tk.BOTH)

    return frame
Ejemplo n.º 20
0
 def create_stopwatch_label(self):
     """Create the stopwatch number display"""
     lbl = ttk.Label(
         master=self,
         font="-size 32",
         anchor=CENTER,
         textvariable=self.stopwatch_text,
     )
     lbl.pack(side=TOP, fill=X, padx=60, pady=20)
Ejemplo n.º 21
0
    def create_form_entry(self, label, variable):
        """Create a single form entry"""
        container = ttk.Frame(self)
        container.pack(fill=X, expand=YES, pady=5)

        lbl = ttk.Label(master=container, text=label.title(), width=10)
        lbl.pack(side=LEFT, padx=5)

        ent = ttk.Entry(master=container, textvariable=variable)
        ent.pack(side=LEFT, padx=5, fill=X, expand=YES)
Ejemplo n.º 22
0
 def create_num_display(self):
     container = ttk.Frame(master=self, padding=2, bootstyle=self.bootstyle)
     container.pack(fill=X, pady=20)
     digits = ttk.Label(
         master=container,
         font="TkFixedFont 14",
         textvariable=self.digitsvar,
         anchor=E,
     )
     digits.pack(fill=X)
Ejemplo n.º 23
0
    def show_toast(self, *_):
        """Create and show the toast window."""

        # build toast
        self.toplevel = ttk.Toplevel(**self.kwargs)
        self._setup(self.toplevel)

        self.container = ttk.Frame(self.toplevel, bootstyle=self.bootstyle)
        self.container.pack(fill=BOTH, expand=YES)
        ttk.Label(
            self.container,
            text=self.icon,
            font=self.iconfont,
            bootstyle=f"{self.bootstyle}-inverse",
            anchor=NW,
        ).grid(row=0, column=0, rowspan=2, sticky=NSEW, padx=(5, 0))
        ttk.Label(
            self.container,
            text=self.title,
            font=self.titlefont,
            bootstyle=f"{self.bootstyle}-inverse",
            anchor=NW,
        ).grid(row=0, column=1, sticky=NSEW, padx=10, pady=(5, 0))
        ttk.Label(
            self.container,
            text=self.message,
            wraplength=utility.scale_size(self.toplevel, 300),
            bootstyle=f"{self.bootstyle}-inverse",
            anchor=NW,
        ).grid(row=1, column=1, sticky=NSEW, padx=10, pady=(0, 5))

        self.toplevel.bind("<ButtonPress>", self.hide_toast)

        # alert toast
        if self.alert:
            self.toplevel.bell()

        # specified duration to close
        if self.duration:
            self.toplevel.after(self.duration, self.hide_toast)
Ejemplo n.º 24
0
 def create_path_row(self):
     """Add path row to labelframe"""
     path_row = ttk.Frame(self.option_lf)
     path_row.pack(fill=X, expand=YES)
     path_lbl = ttk.Label(path_row, text="Path", width=8)
     path_lbl.pack(side=LEFT, padx=(15, 0))
     path_ent = ttk.Entry(path_row, textvariable=self.path_var)
     path_ent.pack(side=LEFT, fill=X, expand=YES, padx=5)
     browse_btn = ttk.Button(master=path_row,
                             text="Browse",
                             command=self.on_browse,
                             width=8)
     browse_btn.pack(side=LEFT, padx=5)
Ejemplo n.º 25
0
def create_progressbar_frame(bootstyle, style, orient, testname):
    frame = ttk.Frame(root, padding=5)

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

    # colored
    for i, color in enumerate(style.colors):
        ttk.Label(frame, text=color).pack(fill=tk.X)
        pb = ttk.Progressbar(master=frame,
                             value=25 + ((i - 1) * 10),
                             bootstyle=(color, bootstyle),
                             orient=orient)
        if orient == 'h':
            pb.pack(padx=5, pady=5, fill=tk.X)
        else:
            pb.pack(padx=5, pady=5, fill=tk.Y)
        pb.start()

    return frame
Ejemplo n.º 26
0
 def create_term_row(self):
     """Add term row to labelframe"""
     term_row = ttk.Frame(self.option_lf)
     term_row.pack(fill=X, expand=YES, pady=15)
     term_lbl = ttk.Label(term_row, text="Term", width=8)
     term_lbl.pack(side=LEFT, padx=(15, 0))
     term_ent = ttk.Entry(term_row, textvariable=self.term_var)
     term_ent.pack(side=LEFT, fill=X, expand=YES, padx=5)
     search_btn = ttk.Button(master=term_row,
                             text="Search",
                             command=self.on_search,
                             bootstyle=OUTLINE,
                             width=8)
     search_btn.pack(side=LEFT, padx=5)
    def create_elements(self):
        """Create the layout elements."""
        container = ttk.Frame(self, padding=10)
        container.pack(fill=BOTH, expand=YES)

        _text = ("Click the START button to begin a long-running task " +
                 "that will last approximately 1 to 15 seconds.")
        wrapped = '\n'.join(textwrap.wrap(_text, width=35))
        lbl = ttk.Label(container, text=wrapped, justify=LEFT)
        lbl.pack(fill=X, pady=10, expand=YES)

        self.start_btn = ttk.Button(master=container,
                                    text='START',
                                    command=self.start_task)
        self.start_btn.pack(fill=X, pady=10)
        self.progressbar = ttk.Progressbar(master=container,
                                           maximum=10,
                                           bootstyle=(STRIPED, SUCCESS))
        self.progressbar.pack(fill=X, expand=YES)
        msg_lbl = ttk.Label(container,
                            textvariable=self.message,
                            anchor=CENTER)
        msg_lbl.pack(fill=X, pady=10)
Ejemplo n.º 28
0
def create_frame_test(bootstyle, style):
    frame = ttk.Frame(padding=10)

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

    # default
    frm = ttk.Frame(frame, style=bootstyle, width=150, height=100)
    frm.pack(padx=5, pady=5)
    frm.pack_propagate(0)
    ttk.Label(frm, text='default').pack(fill=tk.BOTH)

    # color
    for color in style.theme.colors:
        frm = ttk.Frame(frame, bootstyle=color, width=150, height=100)
        frm.pack(padx=5, pady=5)
        frm.pack_propagate(0)
        ttk.Label(master=frm, text=color,
                  bootstyle=(color, 'inverse')).pack(fill=tk.BOTH)

    return frame
Ejemplo n.º 29
0
    def add(self, child, title="", bootstyle=PRIMARY, **kwargs):
        """Add a child to the collapsible frame

        Parameters:

            child (Frame):
                The child frame to add to the widget.

            title (str):
                The title appearing on the collapsible section header.

            bootstyle (str):
                The style to apply to the collapsible section header.

            **kwargs (Dict):
                Other optional keyword arguments.
        """
        if child.winfo_class() != 'TFrame':
            return
        
        style_color = Bootstyle.ttkstyle_widget_color(bootstyle)
        frm = ttk.Frame(self, bootstyle=style_color)
        frm.grid(row=self.cumulative_rows, column=0, sticky=EW)

        # header title
        header = ttk.Label(
            master=frm,
            text=title,
            bootstyle=(style_color, INVERSE)
        )
        if kwargs.get('textvariable'):
            header.configure(textvariable=kwargs.get('textvariable'))
        header.pack(side=LEFT, fill=BOTH, padx=10)

        # header toggle button
        def _func(c=child): return self._toggle_open_close(c)
        btn = ttk.Button(
            master=frm,
            image=self.images[0],
            bootstyle=style_color,
            command=_func
        )
        btn.pack(side=RIGHT)

        # assign toggle button to child so that it can be toggled
        child.btn = btn
        child.grid(row=self.cumulative_rows + 1, column=0, sticky=NSEW)

        # increment the row assignment
        self.cumulative_rows += 2
Ejemplo n.º 30
0
    def constructWithBorder(self, frame: ttk.Frame) -> None:
        self.data.setdefault("text", tk.StringVar(value="0.0"))

        topFrame = ttk.Frame(frame)
        self.label = ttk.Label(topFrame, text=self.name)
        self.entry = ValEntry(ValEntry.type_validator(float),
                              topFrame,
                              textvariable=self.data["text"])

        self.scale = ttk.Scale(frame,
                               orient="horizontal",
                               from_=0.0,
                               to=MAXVAL,
                               command=self._onScaleChange)

        rangeFrame = ttk.Frame(frame)
        self.lowLabel = ttk.Label(rangeFrame)
        self.highLabel = ttk.Label(rangeFrame)

        self.entry.bind("<Return>", lambda _: self._callback("enter"))
        self.entry.bindUpdate(self._calcScale)
        self.entry.bindUpdate(lambda _: self._callback("change"))
        self.scale.bind("<ButtonRelease-1>",
                        lambda _: self._callback("release"))

        rangeFrame.bind("<MouseWheel>", self._onMouseWheel)
        self.scale.bind("<MouseWheel>", self._onMouseWheel)

        topFrame.pack()
        self.label.pack(side="left")
        self.entry.pack(side="left")

        self.scale.pack(fill="x", expand=True)

        rangeFrame.pack(fill="x", expand=True)
        self.lowLabel.pack(side="left")
        self.highLabel.pack(side="right")