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 __init__(self, master, initialcolor=None, padding=None):
        super().__init__(master, padding=padding)
        self.tframe = ttk.Frame(self, padding=5)
        self.tframe.pack(fill=X)
        self.bframe = ttk.Frame(self, padding=(5, 0, 5, 5))
        self.bframe.pack(fill=X)

        self.notebook = ttk.Notebook(self.tframe)
        self.notebook.pack(fill=BOTH)

        self.style = ttk.Style.get_instance()
        self.colors = self.style.colors
        self.initialcolor = initialcolor or self.colors.bg

        # color variables
        r, g, b = ImageColor.getrgb(self.initialcolor)
        h, s, l = colorutils.color_to_hsl((r, g, b), RGB)
        hx = colorutils.color_to_hex((r, g, b), RGB)

        self.hue = ttk.IntVar(value=h)
        self.sat = ttk.IntVar(value=s)
        self.lum = ttk.IntVar(value=l)
        self.red = ttk.IntVar(value=r)
        self.grn = ttk.IntVar(value=g)
        self.blu = ttk.IntVar(value=b)
        self.hex = ttk.StringVar(value=hx)

        # widget sizes (adjusted by widget scaling)
        self.spectrum_height = utility.scale_size(self, 240)
        self.spectrum_width = utility.scale_size(self,
                                                 530)  # looks better on Mac OS
        #self.spectrum_width = utility.scale_size(self, 480)
        self.spectrum_point = utility.scale_size(self, 12)

        # build widgets
        spectrum_frame = ttk.Frame(self.notebook)
        self.color_spectrum = self.create_spectrum(spectrum_frame)
        self.color_spectrum.pack(fill=X, side=TOP)
        self.luminance_scale = self.create_luminance_scale(self.tframe)
        self.luminance_scale.pack(fill=X)
        self.notebook.add(spectrum_frame,
                          text=MessageCatalog.translate('Advanced'))

        themed_colors = [self.colors.get(c) for c in self.style.colors]
        self.themed_swatches = self.create_swatches(self.notebook,
                                                    themed_colors)
        self.standard_swatches = self.create_swatches(self.notebook,
                                                      STD_COLORS)
        self.notebook.add(self.themed_swatches,
                          text=MessageCatalog.translate('Themed'))
        self.notebook.add(self.standard_swatches,
                          text=MessageCatalog.translate('Standard'))
        preview_frame = self.create_preview(self.bframe)
        preview_frame.pack(side=LEFT, fill=BOTH, expand=YES, padx=(0, 5))
        self.color_entries = self.create_value_inputs(self.bframe)
        self.color_entries.pack(side=RIGHT)

        self.create_spectrum_indicator()
        self.create_luminance_indicator()
Ejemplo n.º 3
0
 def __init__(self):
     super().__init__("TTK Creator")
     self.configure_frame = ttk.Frame(self, padding=(10, 10, 5, 10))
     self.configure_frame.pack(side=LEFT, fill=BOTH, expand=YES)
     self.demo_frame = ttk.Frame(self, padding=(5, 10, 10, 10))
     self.demo_frame.pack(side=LEFT, fill=BOTH, expand=YES)
     self.setup_theme_creator()
     self.demo_widgets = DemoWidgets(self, self.style)
     self.demo_widgets.pack(fill=BOTH, expand=YES)
Ejemplo n.º 4
0
 def create_stopwatch_controls(self):
     """Create the control frame with buttons"""
     container = ttk.Frame(self, padding=10)
     container.pack(fill=X)
     self.buttons = []
     self.buttons.append(
         ttk.Button(
             master=container,
             text="Start",
             width=10,
             bootstyle=INFO,
             command=self.on_toggle,
         ))
     self.buttons.append(
         ttk.Button(
             master=container,
             text="Reset",
             width=10,
             bootstyle=SUCCESS,
             command=self.on_reset,
         ))
     self.buttons.append(
         ttk.Button(
             master=container,
             text="Quit",
             width=10,
             bootstyle=DANGER,
             command=self.on_quit,
         ))
     for button in self.buttons:
         button.pack(side=LEFT, fill=X, expand=YES, pady=10, padx=5)
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 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.º 7
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.º 8
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.º 9
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.º 10
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.º 11
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.º 12
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.º 13
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.º 14
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.º 15
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.º 16
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.º 17
0
    def __init__(self,
                 parent_widget,
                 title='',
                 completion_list=None,
                 completion_dict=None,
                 fetch_fct=None,
                 single_choice=False,
                 tooltip=None):
        super().__init__(parent_widget)
        self.parent = parent_widget
        first_row = ttk.Frame(self)
        first_row.pack(side='top', fill='x', pady=5)
        label = ttk.Label(first_row, text=title)
        label.pack(side='left', expand=False)
        if not tooltip:
            tooltip = f"Type characters matching the desired {title} and press <Down> to show available options."
        if fetch_fct:
            ToolTip(label, text=tooltip)
        self.entry = AutocompleteCombobox(first_row,
                                          completion_list=completion_list,
                                          completion_dict=completion_dict,
                                          fetch_fct=fetch_fct,
                                          single_choice=single_choice)
        self.entry.pack(side='left', expand=True, fill="x", padx=10)

        second_row = ttk.Frame(self)
        second_row.pack(side='top', fill='x')
        if single_choice:
            vbar = False
        else:
            vbar = True
        self.labels_text_box = ScrolledText(second_row,
                                            wrap="word",
                                            height=0,
                                            autohide=True,
                                            vbar=vbar)
        self.labels_text_box.pack(side='top', fill='x', padx=5, expand=True)
        self.labels_text_box._text.configure(state="disabled",
                                             highlightthickness=0,
                                             borderwidth=0,
                                             bg=ttk.Style().colors.bg)
        self.labels_text_box.bind("<Configure>", self.resize_text_box)

        self.entry.set_selection_text(self, self.labels_text_box)
Ejemplo n.º 18
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.º 19
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.º 20
0
    def create_swatches(self, master, colors):
        """Create a grid of color swatches"""
        boxpadx = 2
        boxpady = 0
        padxtotal = (boxpadx * 15)
        boxwidth = int((self.spectrum_width - padxtotal)) / len(STD_COLORS)
        boxheight = int(
            (self.spectrum_height - boxpady) / (len(STD_SHADES) + 1))
        container = ttk.Frame(master)

        # create color combinations
        color_rows = [colors]
        lastcol = len(colors) - 1
        for l in STD_SHADES:
            lum = int(l * LUM)
            row = []
            for color in colors:
                color = colorutils.update_hsl_value(color=color,
                                                    lum=lum,
                                                    inmodel='hex',
                                                    outmodel='hex')
                row.append(color)
            color_rows.append(row)

        # themed colors - regular colors
        for row in color_rows:
            rowframe = ttk.Frame(container)
            for j, color in enumerate(row):
                swatch = tkFrame(master=rowframe,
                                 bg=color,
                                 width=boxwidth,
                                 height=boxheight,
                                 autostyle=False)
                swatch.bind('<Button-1>', self.on_press_swatch)
                if j == 0:
                    swatch.pack(side=LEFT, padx=(0, boxpadx))
                elif j == lastcol:
                    swatch.pack(side=LEFT, padx=(boxpadx, 0))
                else:
                    swatch.pack(side=LEFT, padx=boxpadx)
            rowframe.pack(fill=X, expand=YES)

        return container
Ejemplo n.º 21
0
def create_notebook_frame(widget_style, style):
    frame = ttk.Frame(root, padding=5)
    
    # title
    title = ttk.Label(frame, text=widget_style, anchor=tk.CENTER)
    title.pack(padx=5, pady=2, fill=tk.BOTH)
    ttk.Separator(frame).pack(padx=5, pady=5, fill=tk.X)

    # default
    nb = ttk.Notebook(frame, height=50, width=100)
    nb.pack(padx=5, pady=5, fill=tk.BOTH)
    for i, _ in enumerate(style.colors):
        nb.add(ttk.Frame(nb), text=f'Tab {i+1}')

    # other colors
    for color in style.colors:
        nb = ttk.Notebook(frame, bootstyle=color, height=50, width=100)
        nb.pack(padx=5, pady=5, fill=tk.BOTH)
        for i, _ in enumerate(style.colors):
            nb.add(ttk.Frame(nb), text=f'Tab {i+1}')
    return frame
Ejemplo n.º 22
0
def create_panedwindow_frame(widget_style, style):
    frame = ttk.Frame(root, padding=5)

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

    # default
    pw = ttk.Panedwindow(frame)
    pw.pack(padx=5, pady=5, fill=tk.BOTH)
    pw.add(ttk.Frame(pw, width=100, height=50, bootstyle='info'))
    pw.add(ttk.Frame(pw, width=100, height=50, bootstyle='success'))

    for color in style.colors:
        # default
        pw = ttk.Panedwindow(frame, bootstyle=color)
        pw.pack(padx=5, pady=5, fill=tk.BOTH)
        pw.add(ttk.Frame(pw, width=100, height=50))
        pw.add(ttk.Frame(pw, width=100, height=50))

    return frame
Ejemplo n.º 23
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.º 24
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.º 25
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.º 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)
Ejemplo n.º 27
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")
Ejemplo n.º 28
0
 def attach(self, canvas: tk.Canvas, x: int = 10, y: int = 10) -> None:
     if canvas is self.canvas:
         self.canvas.coords(self.dndid, x, y)
         return
     if self.canvas:
         self.detach()
     if not canvas:
         return
     self.canvas = canvas
     self.frame = ttk.Frame(canvas)
     self.construct(self.frame)
     self.afterConstruct()
     self.configureAll(lambda w: w.bind("<ButtonPress-1>", self._on_drag))
     self.dndid = canvas.create_window(x, y, window=self.frame, anchor="nw")
     self.registerCanvas(canvas)
Ejemplo n.º 29
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.º 30
0
    def create_buttonbox(self):
        """Create buttonbox with media controls"""
        container = ttk.Frame(self)
        container.pack(fill=X, expand=YES)
        ttk.Style().configure('TButton', font="-size 14")

        rev_btn = ttk.Button(
            master=container,
            text=Emoji.get(
                'black left-pointing double triangle with vertical bar'),
            padding=10,
        )
        rev_btn.pack(side=LEFT, fill=X, expand=YES)

        play_btn = ttk.Button(
            master=container,
            text=Emoji.get('black right-pointing triangle'),
            padding=10,
        )
        play_btn.pack(side=LEFT, fill=X, expand=YES)

        fwd_btn = ttk.Button(
            master=container,
            text=Emoji.get(
                'black right-pointing double triangle with vertical bar'),
            padding=10,
        )
        fwd_btn.pack(side=LEFT, fill=X, expand=YES)

        pause_btn = ttk.Button(
            master=container,
            text=Emoji.get('double vertical bar'),
            padding=10,
        )
        pause_btn.pack(side=LEFT, fill=X, expand=YES)

        stop_btn = ttk.Button(
            master=container,
            text=Emoji.get('black square for stop'),
            padding=10,
        )
        stop_btn.pack(side=LEFT, fill=X, expand=YES)

        stop_btn = ttk.Button(master=container,
                              text=Emoji.get('open file folder'),
                              bootstyle=SECONDARY,
                              padding=10)
        stop_btn.pack(side=LEFT, fill=X, expand=YES)