Example #1
0
    def __init__(self, container, placeholder, *args, **kwargs):
        super().__init__(container, *args, **kwargs)
        self.placeholder = placeholder

        self.placeholder_color = ttk.Style().colors.secondary
        self.default_fg_color = ttk.Style().colors.inputfg
        self['foreground'] = self.placeholder_color

        self.insert("0", self.placeholder)
        self.bind("<FocusIn>", self._clear_placeholder)
        self.bind("<FocusOut>", self._add_placeholder)
Example #2
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 #3
0
    def __init__(
        self,
        widget,
        text="widget info",
        bootstyle=None,
        wraplength=None,
        **kwargs,
    ):
        """
        Parameters:

            widget (Widget):
                The tooltip window will position over this widget when
                hovering.

            text (str):
                The text to display in the tooltip window.

            bootstyle (str):
                The style to apply to the tooltip label. You can use
                any of the standard ttkbootstrap label styles.

            wraplength (int):
                The width of the tooltip window in screenunits before the
                text is wrapped to the next line. By default, this will be
                a scaled factor of 300.

            **kwargs (Dict):
                Other keyword arguments passed to the `Toplevel` window.
        """
        self.widget = widget
        self.text = text
        self.bootstyle = bootstyle
        self.wraplength = wraplength or utility.scale_size(self.widget, 300)
        self.toplevel = None

        # set keyword arguments
        kwargs["overrideredirect"] = True
        kwargs["master"] = self.widget
        if "alpha" not in kwargs:
            kwargs["alpha"] = 0.95
        self.toplevel_kwargs = kwargs

        # create default tooltip style
        ttk.Style().configure(
            style="tooltip.TLabel",
            background="#fffddd",
            foreground="#333",
            bordercolor="#888",
            borderwidth=1,
            darkcolor="#fffddd",
            lightcolor="#fffddd",
            relief=RAISED,
        )

        # event binding
        self.widget.bind("<Enter>", self.show_tip)
        self.widget.bind("<Leave>", self.hide_tip)
        self.widget.bind("<Motion>", self.move_tip)
        self.widget.bind("<ButtonPress>", self.hide_tip)
Example #4
0
    def __init__(self, master, **kwargs):
        super().__init__(master, padding=10, **kwargs)
        ttk.Style().configure("TButton", font="TkFixedFont 12")
        self.pack(fill=BOTH, expand=YES)
        self.digitsvar = ttk.StringVar(value=0)
        self.xnum = ttk.DoubleVar()
        self.ynum = ttk.DoubleVar()
        self.operator = ttk.StringVar(value="+")

        if "bootstyle" in kwargs:
            self.bootstyle = kwargs.pop("bootstyle")
        else:
            self.bootstyle = None
        self.create_num_display()
        self.create_num_pad()
    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)
Example #6
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 = {}
Example #7
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)
            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

def change_style():
    theme = choice(style.theme_names())
    style.theme_use(theme)



if __name__ == '__main__':
    # create visual widget style tests
    root = tk.Tk()
    style = ttk.Style(theme='minty')

    button_style_frame('date', style, 'Outline Button').pack(side=tk.LEFT)

    ttk.Button(text="Change Theme", command=change_style).pack(padx=10, pady=10)

    root.mainloop()
        state=tk.DISABLED
    )
    cb.pack(padx=5, pady=5, fill=tk.BOTH)
    cb.invoke()

    return frame

def change_style():
    theme = choice(style.theme_names())
    style.theme_use(theme)


if __name__ == '__main__':
    # create visual widget style tests
    root = tk.Tk()
    style = ttk.Style(theme=LIGHT)

    test1 = create_checkbutton_test('', style, 'Checkbutton')
    test1.pack(side=tk.LEFT, fill=tk.BOTH)
    test2 = create_checkbutton_test('round-toggle', style, 'Roundtoggle')
    test2.pack(side=tk.LEFT, fill=tk.BOTH)
    test3 = create_checkbutton_test('square-toggle', style, 'Squaretoggle')
    test3.pack(side=tk.LEFT, fill=tk.BOTH)
    test4 = create_checkbutton_test('toolbutton', style, 'Toolbutton')
    test4.pack(side=tk.LEFT, fill=tk.BOTH)
    test5 = create_checkbutton_test('outline-toolbutton', style, 'Outline Toolbutton')
    test5.pack(side=tk.LEFT, fill=tk.BOTH)

    btn = ttk.Button(text="Change Theme", command=change_style)
    btn.pack(padx=10, pady=10)    
Example #10
0
    results = [b.split(":")[1][1:-1] for b in results if "Key Content" in b]
    nameAndPass[i] = results

# Get the Type of security for each of theme and store the SSID and typeOfSecurity in our dic nameAndType
for i in SSID_name:
    results = subprocess.check_output(
        ["netsh", "wlan", "show", "profile", i,
         "key=clear"]).decode("utf-8").split("\n")
    get_security_type = [
        b.split(":")[1][1:-1] for b in results if "Authentication" in b
    ]
    nameAndType[i] = get_security_type
# ------------------------------------------------End--------------------------------------------------------

# Bootstrap Theme & Style Objects
S = ttkbootstrap.Style(theme="flatly")
s = ttk.Style()

# Make  Window
main_window = S.master
main_window.title("QrCode Maker")
main_window.resizable(False, False)
main_window.config(bg="#f6f6f7")

# put the window size and Positions the window in the center of the screen
main_window.geometry("450x500+{}+{}".format(
    postion(main_window, 450, 500)[0],
    postion(main_window, 450, 500)[1]))

# App Icon
main_window.iconbitmap("AppIcon.ico")
Example #11
0
    def __init__(self, isServer: bool = False):
        style = ttk.Style("cosmo")
        self._root = style.master
        self._root.title("FBPos")
        self._root.protocol("WM_DELETE_WINDOW", self.shutdown)
        self._root.rowconfigure(0, weight=1)
        self._root.columnconfigure(0, weight=1)

        self._recv = FBFloatMultiRecv()
        self._client = FBServer() if isServer else FBClient()
        self._client.registerRecvCallback(self._recv.input)

        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._fig.subplots_adjust(top=0.965,
                                  bottom=0.055,
                                  left=0.115,
                                  right=0.97,
                                  wspace=0,
                                  hspace=0)
        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_aspect("equal", adjustable="datalim")

        self._toolbar = NavigationToolbar2Tk(self._canvas,
                                             self._plotFrame,
                                             pack_toolbar=False)
        self._toolbar.update()
        self._hiddenPanButton = self._toolbar._buttons["Pan"]
        self._prePanState = False

        self._canvas.mpl_connect("button_press_event", self._control_on_press)
        self._canvas.mpl_connect("button_release_event",
                                 self._control_on_release)
        self._canvas.mpl_connect("motion_notify_event", self._control_on_move)
        self._control_event: SimpleNamespace = None
        self._control_event_lock = threading.Lock()
        self._control_arrow = FancyArrow(0, 0, 1, 0, width=0.1)
        self._ax.add_patch(self._control_arrow)
        self._control_arrow.set_visible(False)

        self._opFrame = ttk.Frame(self._root)
        self._opFrame.grid(row=1, column=0, sticky="we")

        self._resetLimButton = ttk.Button(self._opFrame,
                                          text="视野重置",
                                          command=self._resetLim)
        self._resetLimButton.pack(side="left", padx=5, pady=5)

        self._panButton = ttk.Checkbutton(
            self._opFrame,
            text="拖拽",
            bootstyle=("warning", "outline", "toolbutton"),
            command=self._onPanClick,
        )
        self._panButton.pack(side="left", padx=5, pady=5)

        self._controlButton = ttk.Checkbutton(
            self._opFrame,
            text="控制",
            bootstyle=("error", "outline", "toolbutton"),
            command=self._onControlClick,
        )
        self._controlButton.pack(side="left", padx=5, pady=5)

        self._pauseButton = ttk.Checkbutton(self._opFrame,
                                            text="暂停",
                                            bootstyle=("success", "outline",
                                                       "toolbutton"))
        self._pauseButton.pack(side="left", padx=5, pady=5)

        self._resetPosButton = ttk.Button(self._opFrame,
                                          text="重置位置",
                                          command=self._resetPos)
        self._resetPosButton.pack(side="left", padx=5, pady=5)

        self._stopButton = ttk.Button(self._opFrame,
                                      text="停止",
                                      command=self._stop)
        self._stopButton.pack(side="left", padx=5, pady=5)

        self._robots: List[Robot] = []
        self._scatters: List[Scatter] = []
Example #12
0
import tkinter as tk
import ttkbootstrap as ttk
from ttkbootstrap import utility
utility.enable_high_dpi_awareness()

root = tk.Tk()
style = ttk.Style('superhero')

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

top_frame = ttk.Frame(frame)
bot_frame = ttk.Frame(frame)
top_frame.pack(fill=tk.X)
bot_frame.pack(fill=tk.X)

# --- Testing below ---

# radiobutton
for i, color in enumerate(['default', *style.colors]):
    if i < 5:
        a = ttk.Radiobutton(top_frame,
                            text=color,
                            bootstyle=color,
                            width=12,
                            value=1)
    else:
        a = ttk.Radiobutton(bot_frame,
                            text=color,
                            bootstyle=color,
                            width=12,
import tkinter as tk
import ttkbootstrap as ttk
from ttkbootstrap import utility
utility.enable_high_dpi_awareness()

root = tk.Tk()
style = ttk.Style(theme='darkly')

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

top_frame = ttk.Frame(frame)
bot_frame = ttk.Frame(frame)
top_frame.pack(fill=tk.X)
bot_frame.pack(fill=tk.X)

# --- Testing below ---

# checkbutton
for i, color in enumerate(['default', *style.colors]):
    if i < 5:
        a = ttk.Checkbutton(top_frame, text=color, bootstyle=color, width=12)
    else:
        a = ttk.Checkbutton(bot_frame, text=color, bootstyle=color, width=12)

    a.pack(side=tk.LEFT, padx=3, pady=10)
    a.invoke()
a = ttk.Checkbutton(bot_frame, text='disabled', width=12, state=tk.DISABLED)
a.pack(side=tk.LEFT, padx=3, pady=10)

# solid toolbutton
Example #14
0
import ttkbootstrap as ttk
from os.path import join, dirname
from sys import executable
from subprocess import Popen, DETACHED_PROCESS
from math import sqrt, floor, ceil

DIR = dirname(__file__)
APPs = ["FBSerial", "FBPlot", "FBPanel", "FBRot", "FBImg", "FBRecorder", "FBPos", "FBMapDraw", "FBMapSend"]

if __name__ == "__main__":
    style = ttk.Style("cosmo")
    root = style.master
    root.title("launcher")
    root.resizable(False, False)
    C = ceil(len(APPs) / floor(sqrt(len(APPs))))
    for i, app in enumerate(APPs):
        ttk.Button(
            root,
            text=app,
            command=lambda app=app: Popen([executable, join(DIR, app, "main.py")], creationflags=DETACHED_PROCESS),
        ).grid(row=i // C, column=i % C, padx=5, pady=5, sticky="nsew")
    root.mainloop()
Example #15
0
    def __init__(self, tk_parent, linkedin_conn):

        self.parent = tk_parent
        self.linkedin_conn = linkedin_conn

        self.search_results_df = pd.DataFrame()
        self.search_thread = None
        self.quick_search = True

        # Paned Window
        self.search_paned_window = ttk.PanedWindow(tk_parent,
                                                   orient='horizontal')
        self.search_paned_window.pack(side='top',
                                      fill="both",
                                      expand=True,
                                      padx=10)

        ## Search fields Canvas/ScrolledFrame
        search_fields_canvas = ttk.Canvas(self.search_paned_window)

        search_fields_frame = ScrolledFrame(search_fields_canvas)
        search_fields_frame.pack(side='top', fill='both', expand=True, padx=5)
        search_fields_frame.hide_scrollbars()

        ### Load/Save search
        load_save_btn_frame = ttk.Frame(search_fields_frame)
        load_save_btn_frame.pack(pady=5, side='top', fill="x")

        load_search_btn = ttk.Button(load_save_btn_frame, text="Load param.")
        load_search_btn.pack(side='left')
        load_search_btn['command'] = self.load_search_config

        save_search_btn = ttk.Button(load_save_btn_frame, text="Save param.")
        save_search_btn.pack(side='right', padx=10)
        save_search_btn['command'] = self.save_search_config

        ### Connections
        conn_frame = ttk.Frame(search_fields_frame)
        conn_frame.pack(pady=10, side='top', fill='x')
        conn_lbl = ttk.Label(conn_frame, text="Connections")
        conn_lbl.pack(side='left', expand=False)
        ToolTip(conn_lbl,
                text=f"Degree of Connection with the logged in user.")

        first_con = ttk.BooleanVar()
        second_con = ttk.BooleanVar()
        third_con = ttk.BooleanVar()

        self.con_dict_list = [{
            'bool_val': first_con,
            'name': 'F'
        }, {
            'bool_val': second_con,
            'name': 'S'
        }, {
            'bool_val': third_con,
            'name': 'O'
        }]

        ttk.Checkbutton(conn_frame,
                        text="1st",
                        variable=first_con,
                        bootstyle="primary").pack(side='left', padx=10)
        ttk.Checkbutton(conn_frame,
                        text="2nd",
                        variable=second_con,
                        bootstyle="primary").pack(side='left', padx=10)
        ttk.Checkbutton(conn_frame,
                        text="3rd+",
                        variable=third_con,
                        bootstyle="primary").pack(side='left', padx=10)

        ttk.Separator(search_fields_frame,
                      orient='horizontal').pack(side='top', fill='x', pady=5)

        ### Connection of
        self.conn_of_frame = SearchFrame(
            search_fields_frame,
            title='Connection of',
            single_choice=True,
            fetch_fct=lambda x: utils.extract_urn_dict_from_query_results(
                linkedin_conn[0].get_contact_urn_ids, x))
        self.conn_of_frame.pack(side='top', fill="x")

        ttk.Separator(search_fields_frame,
                      orient='horizontal').pack(side='top', fill='x', pady=5)

        ### Location Frame
        self.loc_frame = SearchFrame(
            search_fields_frame,
            title='Location',
            fetch_fct=lambda x: utils.extract_urn_dict_from_query_results(
                linkedin_conn[0].get_geo_urn_ids, x))
        self.loc_frame.pack(side='top', fill="x")

        ttk.Separator(search_fields_frame,
                      orient='horizontal').pack(side='top', fill='x', pady=5)

        ### Current Company frame
        self.current_comp_frame = SearchFrame(
            search_fields_frame,
            title='Current Company',
            fetch_fct=lambda x: utils.extract_urn_dict_from_query_results(
                linkedin_conn[0].get_company_urn_ids, x))
        self.current_comp_frame.pack(side='top', fill="x")

        ttk.Separator(search_fields_frame,
                      orient='horizontal').pack(side='top', fill='x', pady=5)

        ### Past Company frame
        self.past_comp_frame = SearchFrame(
            search_fields_frame,
            title='Past Company',
            fetch_fct=lambda x: utils.extract_urn_dict_from_query_results(
                linkedin_conn[0].get_company_urn_ids, x))
        self.past_comp_frame.pack(side='top', fill="x", pady=5)

        ttk.Separator(search_fields_frame,
                      orient='horizontal').pack(side='top', fill='x', pady=5)

        ### School frame
        self.school_frame = SearchFrame(
            search_fields_frame,
            title='School',
            fetch_fct=lambda x: utils.extract_urn_dict_from_query_results(
                linkedin_conn[0].get_school_urn_ids, x))
        self.school_frame.pack(side='top', fill="x", pady=5)

        ttk.Separator(search_fields_frame,
                      orient='horizontal').pack(side='top', fill='x', pady=5)

        ### Industry frame
        self.industry_frame = SearchFrame(
            search_fields_frame,
            title='Industry',
            fetch_fct=lambda x: utils.extract_urn_dict_from_query_results(
                linkedin_conn[0].get_industry_urn_ids, x))
        self.industry_frame.pack(side='top', fill="x", pady=5)

        ### KW-Header
        kw_header_frame = ttk.Frame(search_fields_frame)
        kw_header_frame.pack(pady=5, side='top', fill="x")
        ttk.Label(kw_header_frame, text="Keywords").pack(side='left')
        ttk.Separator(kw_header_frame, orient='horizontal').pack(side='left',
                                                                 fill='x',
                                                                 expand=True)

        ### KW-Frame
        kw_frame = ttk.Frame(search_fields_frame)
        kw_frame.pack(pady=5, side='top', fill="x")
        kw_frame.grid_columnconfigure(0, weight=1)
        kw_frame.grid_columnconfigure(1, weight=1)
        kw_frame.grid_rowconfigure(0, weight=1)
        kw_frame.grid_rowconfigure(1, weight=1)
        kw_frame.grid_rowconfigure(2, weight=1)

        #### General
        self.entry_keywords = PlaceholderEntry(kw_frame, 'General')
        self.entry_keywords.grid(row=0,
                                 column=0,
                                 sticky='nwse',
                                 padx=5,
                                 pady=4)

        #### First Name
        self.entry_keywords_first_name = PlaceholderEntry(
            kw_frame, 'First Name')
        self.entry_keywords_first_name.grid(row=0,
                                            column=1,
                                            sticky='nwse',
                                            padx=5,
                                            pady=4)

        #### Last Name
        self.entry_keywords_last_name = PlaceholderEntry(kw_frame, 'Last Name')
        self.entry_keywords_last_name.grid(row=1,
                                           column=0,
                                           sticky='nwse',
                                           padx=5,
                                           pady=4)

        #### Title
        self.entry_keywords_title = PlaceholderEntry(kw_frame, 'Title')
        self.entry_keywords_title.grid(row=1,
                                       column=1,
                                       sticky='nwse',
                                       padx=5,
                                       pady=4)

        #### Company
        self.entry_keywords_company = PlaceholderEntry(kw_frame, 'Company')
        self.entry_keywords_company.grid(row=2,
                                         column=0,
                                         sticky='nwse',
                                         padx=5,
                                         pady=4)

        #### School
        self.entry_keywords_school = PlaceholderEntry(kw_frame, 'School')
        self.entry_keywords_school.grid(row=2,
                                        column=1,
                                        sticky='nwse',
                                        padx=5,
                                        pady=4)

        self.search_paned_window.add(search_fields_canvas)

        ## Table frame
        self.table_main_frame = ttk.Frame(tk_parent)
        # pandastable
        self.table_frame = ttk.Frame(self.table_main_frame,
                                     bootstyle="secondary",
                                     borderwidth=2)
        self.table_frame.pack(side="top", fill="both", expand=True)
        self.table = Table(self.table_frame,
                           dataframe=pd.DataFrame(),
                           showtoolbar=False,
                           showstatusbar=True)
        utils.fit_table_style_to_theme(self.table, ttk.Style())
        self.table.unbind_all("<Tab>")
        self.table.unbind_all("<Return>")
        self.table.show()

        self.search_paned_window.add(self.table_main_frame)

        # Buttons frame
        btn_frame = ttk.Frame(tk_parent)
        btn_frame.pack(padx=10, pady=10, side='top', fill="x")

        quick_search_btn = ttk.Button(btn_frame, text="Quick search")
        quick_search_btn.pack(side='left', padx=10)
        quick_search_btn['command'] = self.start_quick_search
        ToolTip(
            quick_search_btn,
            "This is a single request that will yield the same results as in the linkedin search bar. \
\nIt doesn't contain any personal details (only public IDs) \
\nYou're not likely to reach any search limit using this mode.")

        btn_sub_frame = ttk.Frame(btn_frame)
        btn_sub_frame.pack(side="left", fill="none", expand=True)

        start_search_btn = ttk.Button(btn_sub_frame,
                                      text="Deep Search",
                                      bootstyle='danger')
        start_search_btn.pack(side='left', padx=10)
        start_search_btn['command'] = self.start_deep_search
        ToolTip(
            start_search_btn,
            "Each search result will be fetched for additional information. \
            \nDepending on the number of results and search frequency, this can trigger the linkedin limit \
after which you'll only be able to get 3 results per search until the end of the month."
        )

        self.get_skills = ttk.BooleanVar()
        skills_chk_btn = ttk.Checkbutton(btn_sub_frame,
                                         text="Fetch skills",
                                         variable=self.get_skills,
                                         bootstyle="danger")
        skills_chk_btn.pack(side='left', padx=10)
        ToolTip(
            skills_chk_btn,
            text=f"Fetch skills by running one additional request per result.")

        self.get_contact_info = ttk.BooleanVar()
        contact_info_chk_btn = ttk.Checkbutton(btn_sub_frame,
                                               text="Fetch contact info",
                                               variable=self.get_contact_info,
                                               bootstyle="danger")
        contact_info_chk_btn.pack(side='left', padx=10)
        ToolTip(
            contact_info_chk_btn,
            text=
            f"Fetch contact info by running one additional request per result."
        )

        self.export_to_file_btn = ttk.Button(btn_frame,
                                             text="Export to File",
                                             state="disabled")
        self.export_to_file_btn.pack(side='left', padx=10)
        self.export_to_file_btn[
            'command'] = self.prepare_dataframe_and_save_to_xsl

        # Status frame
        self.status_frame = ttk.Frame(tk_parent)
        self.status_frame.pack(padx=10,
                               pady=2,
                               side='bottom',
                               expand=False,
                               fill="x")
        self.status_str = ttk.StringVar(value="")
        ttk.Label(self.status_frame,
                  textvariable=self.status_str).pack(side='left', expand=False)

        ttk.Separator(tk_parent, orient='horizontal').pack(side='bottom',
                                                           fill='x')
Example #16
0
import tkinter as tk
import ttkbootstrap as ttk
from ttkbootstrap import utility
utility.enable_high_dpi_awareness()

DARK = 'superhero'
LIGHT = 'flatly'

if __name__ == '__main__':
    # create visual widget style tests
    root = tk.Tk()
    style = ttk.Style(theme=DARK)

    menu = tk.Menu(root)
    for x in range(5):
        menu.insert_checkbutton('end', label=f'Option {x+1}')
    menu.post(100, 100)

    root.mainloop()
Example #17
0
def SelectDirectory():
    WickedDirectories.wickedRootDirectory = filedialog.askdirectory(
        initialdir="../../../", title="Select Wicked Folder")
    WickedDirectories.wickedRootDirectorySelected = True


#endregio

if __name__ == "__main__":
    #region Tk Interface variables

    window = TkBootstrap.Window()
    window.title("Wicked Engine Installer")
    window.resizable(False, False)
    style = TkBootstrap.Style("darkly")

    screenWidth = int(window.winfo_screenwidth() / 3)
    screenHeight = int(window.winfo_screenheight() / 5)

    #endregion

    #region Tk Interface widgets

    button_install = TkBootstrap.Button(text="start install",
                                        bootstyle='success',
                                        command=Install)
    button_path = TkBootstrap.Button(text="select source folder",
                                     bootstyle='default',
                                     command=SelectDirectory)
    checkButton_denoiser = TkBootstrap.Checkbutton(
Example #18
0
    def __init__(self, isServer: bool = False):
        style = ttk.Style("cosmo")
        self._root = style.master
        self._root.title("FBImg")
        self._root.rowconfigure(0, weight=1)
        self._root.columnconfigure(0, weight=1)
        self._root.protocol("WM_DELETE_WINDOW", self.shutdown)

        self._imgCanvas = ttk.Canvas(self._root)
        self._imgCanvas.config(bg="light gray")
        self._imgCanvas.grid(row=0, column=0, sticky="nsew")
        self._imgCanvas_shape = (0, 0)

        opFrame = ttk.Frame(self._root)
        opFrame.grid(row=1, column=0, sticky="we")
        opFrame.columnconfigure(0, weight=1)

        val = lambda s: ValEntry.type_validator(int)(s) and int(s) > 0
        imgFrame = ttk.Frame(opFrame)
        imgFrame.grid(row=0, column=0, sticky="we")
        ttk.Label(imgFrame, text="宽度").pack(side="left", pady=5)
        self.wEntry = ValEntry(val, imgFrame, width=5)
        self.wEntry.pack(side="left", pady=5)
        ttk.Label(imgFrame, text="高度").pack(side="left", pady=5)
        self.hEntry = ValEntry(val, imgFrame, width=5)
        self.hEntry.pack(side="left", pady=5)
        ttk.Button(imgFrame, text="应用",
                   command=self._applySize).pack(side="left", padx=2, pady=5)

        self._pauseButton = ttk.Checkbutton(imgFrame,
                                            text="暂停",
                                            bootstyle=("success", "outline",
                                                       "toolbutton"))
        self._pauseButton.pack(side="left", padx=5, pady=5)

        ttk.Label(imgFrame, text="保存路径").pack(side="left", pady=5)
        self._dirEntry = ttk.Entry(imgFrame, width=30)
        self._dirEntry.pack(side="left", pady=5)

        ttk.Button(imgFrame, text="选择",
                   command=self._selectDir).pack(side="left", pady=5)

        self._saveButton = ttk.Button(imgFrame,
                                      text="保存",
                                      bootstyle=("success"),
                                      command=self.saveImg)
        self._saveButton.pack(side="left", padx=5, pady=5)
        self._recordButton = ttk.Checkbutton(imgFrame,
                                             text="录制",
                                             command=self._toggleRecord,
                                             bootstyle=("warning", "outline",
                                                        "toolbutton"))
        self._recordButton.pack(side="left", pady=5)
        self._cntLabel = ttk.Label(imgFrame)
        self._cntLabel.pack(side="left", pady=5)

        self._client = FBServer() if isServer else FBClient()
        self._recv = FBRawRecv()

        self._client.registerRecvCallback(self._recv.input)
        self._recv.registerRecvCallback(self.updateData)

        self._imgLock = threading.Lock()
        self._dirLock = threading.Lock()
        self.loadConfig()
    def __init__(self, tk_parent, linkedin_conn):

        self.parent = tk_parent
        self.linkedin_conn = linkedin_conn

        self.search_results_df = pd.DataFrame()
        self.search_thread = None
        self.quick_search = True

        # Paned Window
        self.search_paned_window = ttk.PanedWindow(tk_parent, orient='horizontal')
        self.search_paned_window.pack(side='top', fill="both", expand=True, padx=10)

        ## Search fields Canvas/ScrolledFrame
        search_fields_canvas = ttk.Canvas(self.search_paned_window)

        search_fields_frame = ScrolledFrame(search_fields_canvas)
        search_fields_frame.pack(side='top', fill='both', expand=True, padx=5)
        search_fields_frame.hide_scrollbars()

        ### Load/Save search
        load_save_btn_frame = ttk.Frame(search_fields_frame)
        load_save_btn_frame.pack(pady=5, side='top', fill="x")

        load_search_btn = ttk.Button(load_save_btn_frame, text="Load param.")
        load_search_btn.pack(side='left')
        load_search_btn['command'] = self.load_search_config

        save_search_btn = ttk.Button(load_save_btn_frame, text="Save param.")
        save_search_btn.pack(side='right', padx=10)
        save_search_btn['command'] = self.save_search_config

        ### KW-Frame
        kw_frame = ttk.Frame(search_fields_frame)
        kw_frame.pack(pady=5, side='top', fill="x")
        ttk.Label(kw_frame, text="Keywords").pack(side='left')
        self.entry_keywords = ttk.Entry(kw_frame)
        self.entry_keywords.pack(side='left', padx=10, fill='x', expand=True)

        ttk.Separator(search_fields_frame, orient='horizontal').pack(side='top', fill='x', pady=5)
        
        ### Radio Frame
        radio_frame = ttk.Frame(search_fields_frame)
        radio_frame.pack(side='top', fill="x", pady=5, expand=True)
        radio_frame.grid_columnconfigure(0,weight=0)
        radio_frame.grid_columnconfigure(1,weight=0)
        radio_frame.grid_columnconfigure(2,weight=1)

        #### Sort by
        ttk.Label(radio_frame, text="Sort by").grid(row=0, column=0, sticky='nwse')

        self.sort_by = ttk.StringVar(value="R")
        ttk.Radiobutton(radio_frame, text='Most recent', variable=self.sort_by, value="DD").grid(row=0, column=1, padx=10, sticky='nwse')
        ttk.Radiobutton(radio_frame, text='Most relevant', variable=self.sort_by, value="R").grid(row=0, column=2, padx=10, sticky='nwse')

        ttk.Separator(radio_frame, orient='horizontal').grid(row=1, columnspan=3, pady=5, sticky='nwse')

        #### Date Posted
        ttk.Label(radio_frame, text="Date Posted").grid(row=2, column=0, sticky='nwse', pady=5)

        self.date_posted = ttk.IntVar(value=365) # Days since job was posted
        ttk.Radiobutton(radio_frame, text='Past 24h', variable=self.date_posted,
                        value=1).grid(row=3, column=1, padx=10, pady=4, sticky='nwse')
        ttk.Radiobutton(radio_frame, text='Past Week', variable=self.date_posted,
                        value=7).grid(row=3, column=2, padx=10, pady=4, sticky='nwse')
        ttk.Radiobutton(radio_frame, text='Past Month', variable=self.date_posted,
                        value=30).grid(row=4, column=1, padx=10, pady=4, sticky='nwse')
        ttk.Radiobutton(radio_frame, text='Any Time', variable=self.date_posted,
                        value=365).grid(row=4, column=2, padx=10, pady=4, sticky='nwse')

        ttk.Separator(search_fields_frame, orient='horizontal').pack(side='top', fill='x', pady=5)

        ### Experience
        exp_frame = ttk.Frame(search_fields_frame)
        exp_frame.pack(side='top', fill="x")
        exp_frame.grid_columnconfigure(0,weight=0)
        exp_frame.grid_columnconfigure(1,weight=0)
        exp_frame.grid_columnconfigure(2,weight=1)
        ttk.Label(exp_frame, text="Experience").grid(row=0, column=0, pady=4, sticky='nwse')

        intern_lvl_bool = ttk.BooleanVar()
        entry_lvl_bool = ttk.BooleanVar()
        associate_bool = ttk.BooleanVar()
        mid_senior_bool = ttk.BooleanVar()
        director_bool = ttk.BooleanVar()
        executive_bool = ttk.BooleanVar()

        self.exp_dict_list = [
                {'bool_val': intern_lvl_bool, 'name': '1'},
                {'bool_val': entry_lvl_bool, 'name': '2'},
                {'bool_val': associate_bool, 'name': '3'},
                {'bool_val': mid_senior_bool, 'name': '4'},
                {'bool_val': director_bool, 'name': '5'},
                {'bool_val': executive_bool, 'name': '6'},
        ]

        ttk.Checkbutton(exp_frame, text="Internship",
                variable=intern_lvl_bool).grid(row=1, column=0, padx=5, pady=4, sticky='nwse')
        ttk.Checkbutton(exp_frame, text="Entry level",
                variable=entry_lvl_bool).grid(row=1, column=1, padx=5, pady=4, sticky='nwse')
        ttk.Checkbutton(exp_frame, text="Associate",
                variable=associate_bool).grid(row=1, column=2, padx=5, pady=4, sticky='nwse')
        ttk.Checkbutton(exp_frame, text="Mid-Senior level",
                variable=mid_senior_bool).grid(row=2, column=0, padx=5, pady=4, sticky='nwse')
        ttk.Checkbutton(exp_frame, text="Director",
                variable=director_bool).grid(row=2, column=1, padx=5, pady=4, sticky='nwse')
        ttk.Checkbutton(exp_frame, text="Executive",
                variable=executive_bool).grid(row=2, column=2, padx=5, pady=4, sticky='nwse')

        ttk.Separator(search_fields_frame, orient='horizontal').pack(side='top', fill='x', pady=5)

        ### Company frame
        self.comp_frame = SearchFrame(search_fields_frame, title='Company',
                    fetch_fct=lambda x: utils.extract_urn_dict_from_query_results(linkedin_conn[0].get_company_urn_ids, x))
        self.comp_frame.pack(side='top', fill="x")

        ttk.Separator(search_fields_frame, orient='horizontal').pack(side='top', fill='x', pady=5)

        ### Job Type
        job_type_frame = ttk.Frame(search_fields_frame)
        job_type_frame.pack(side='top', fill="x")
        job_type_frame.grid_columnconfigure(0,weight=0)
        job_type_frame.grid_columnconfigure(1,weight=0)
        job_type_frame.grid_columnconfigure(2,weight=1)
        ttk.Label(job_type_frame, text="Job Type").grid(row=0, column=0, pady=4, sticky='nwse')

        full_time_bool = ttk.BooleanVar()
        part_time_bool = ttk.BooleanVar()
        temporary_bool = ttk.BooleanVar()
        contract_bool = ttk.BooleanVar()
        volunteer_bool = ttk.BooleanVar()
        intern_type_bool = ttk.BooleanVar()
        other_type_bool = ttk.BooleanVar()

        self.job_type_dict_list = [
                {'bool_val': full_time_bool, 'name': 'F'},
                {'bool_val': part_time_bool, 'name': 'P'},
                {'bool_val': temporary_bool, 'name': 'T'},
                {'bool_val': contract_bool, 'name': 'C'},
                {'bool_val': volunteer_bool, 'name': 'V'},
                {'bool_val': intern_type_bool, 'name': 'I'},
                {'bool_val': other_type_bool, 'name': 'O'},
        ]

        ttk.Checkbutton(job_type_frame, text="Other",
                variable=other_type_bool).grid(row=0, column=2, padx=10, pady=4, sticky='nwse')
        ttk.Checkbutton(job_type_frame, text="Full-time",
                variable=full_time_bool).grid(row=1, column=0, padx=10, pady=4, sticky='nwse')
        ttk.Checkbutton(job_type_frame, text="Part-time",
                variable=part_time_bool).grid(row=1, column=1, padx=10, pady=4, sticky='nwse')
        ttk.Checkbutton(job_type_frame, text="Temporary",
                variable=temporary_bool).grid(row=1, column=2, padx=10, pady=4, sticky='nwse')
        ttk.Checkbutton(job_type_frame, text="Contract",
                variable=contract_bool).grid(row=2, column=0, padx=10, pady=4, sticky='nwse')
        ttk.Checkbutton(job_type_frame, text="Volunteer",
                variable=volunteer_bool).grid(row=2, column=1, padx=10, pady=4, sticky='nwse')
        ttk.Checkbutton(job_type_frame, text="Internship",
                variable=intern_type_bool).grid(row=2, column=2, padx=10, pady=4, sticky='nwse')
        
        ttk.Separator(search_fields_frame, orient='horizontal').pack(side='top', fill='x', pady=5)

        ### Location Fallback
        self.loc_fallback_frame = SearchFrame(search_fields_frame, title='General Location', single_choice=True,
                    fetch_fct=lambda x: utils.extract_urn_dict_from_query_results(linkedin_conn[0].get_geo_urn_ids, x),
                    tooltip="Restrict the geographical area of the results. In the browser, your location will be recognized automatically and shown at the top of the search page close to the keyword field.")
        self.loc_fallback_frame.pack(side='top', fill="x")

        ### Location Frame
        self.loc_frame = SearchFrame(search_fields_frame, title='Location',
                    fetch_fct=lambda x: utils.extract_urn_dict_from_query_results(linkedin_conn[0].get_geo_urn_ids, x))
        self.loc_frame.pack(side='top', fill="x")

        ttk.Separator(search_fields_frame, orient='horizontal').pack(side='top', fill='x', pady=5)

        ### Industry frame
        self.industry_frame = SearchFrame(search_fields_frame, title='Industry',
                    fetch_fct=lambda x: utils.extract_urn_dict_from_query_results(linkedin_conn[0].get_industry_urn_ids, x))
        self.industry_frame.pack(side='top', fill="x", pady=5)

        self.search_paned_window.add(search_fields_canvas)

        ## Table frame
        self.table_main_frame = ttk.Frame(tk_parent)
        # pandastable
        self.table_frame = ttk.Frame(self.table_main_frame, bootstyle="secondary", borderwidth=2)
        self.table_frame.pack(side="top", fill="both", expand=True)
        self.table = Table(self.table_frame, dataframe=pd.DataFrame(), showtoolbar=False, showstatusbar=True)
        utils.fit_table_style_to_theme(self.table, ttk.Style())
        self.table.unbind_all("<Tab>")
        self.table.unbind_all("<Return>")
        self.table.show()

        self.search_paned_window.add(self.table_main_frame)

        # Buttons frame
        btn_frame = ttk.Frame(tk_parent)
        btn_frame.pack(padx=10, pady=10, side='top', fill="x")

        quick_search_btn = ttk.Button(btn_frame, text="Quick search")
        quick_search_btn.pack(side='left', padx=10)
        quick_search_btn['command'] = self.start_quick_search
        ToolTip(quick_search_btn, "This is a single request that will yield the same results as in the linkedin search bar. \
\nIt doesn't contain any personal details (only public IDs) \
\nYou're not likely to reach any search limit using this mode.")


        btn_sub_frame = ttk.Frame(btn_frame)
        btn_sub_frame.pack(side="left", fill="none", expand=True)

        start_search_btn = ttk.Button(btn_sub_frame, text="Deep Search", bootstyle='danger')
        start_search_btn.pack(side='left', padx=10)
        start_search_btn['command'] = self.start_deep_search
        ToolTip(start_search_btn, "Each search result will be fetched for additional information. \
            \nDepending on the number of results and search frequency, this can trigger the linkedin limit \
after which you'll only be able to get 3 results per search until the end of the month.")

        # self.get_contact_info = ttk.BooleanVar()
        # contact_info_chk_btn = ttk.Checkbutton(btn_sub_frame, text="Fetch contact info",
        #                             variable=self.get_contact_info, bootstyle="danger")
        # contact_info_chk_btn.pack(side='left', padx=10)
        # ToolTip(contact_info_chk_btn, text=f"Fetch contact info by running one additional request per result.")

        self.export_to_file_btn = ttk.Button(btn_frame, text="Export to File", state="disabled")
        self.export_to_file_btn.pack(side='left', padx=10)
        self.export_to_file_btn['command'] = self.prepare_dataframe_and_save_to_xsl

        # Status frame
        self.status_frame = ttk.Frame(tk_parent)
        self.status_frame.pack(padx=10, pady=2, side='bottom', expand=False, fill="x")
        self.status_str = ttk.StringVar(value="")
        ttk.Label(self.status_frame, textvariable=self.status_str).pack(side='left', expand=False)

        ttk.Separator(tk_parent, orient='horizontal').pack(side='bottom', fill='x')
Example #20
0
import ctypes
import tkinter as tk
import tkinter.ttk as ttk
import ttkbootstrap as ts

# 告诉操作系统使用程序自身的dpi适配
ctypes.windll.shcore.SetProcessDpiAwareness(1)
# 获取屏幕的缩放因子
ScaleFactor = ctypes.windll.shcore.GetScaleFactorForDevice(0)
style = ts.Style()
style = ts.Style(theme='litera')


root = style.master
root.title('多页面测试')
root.geometry('800x400')
tab_main=ttk.Notebook()#创建分页栏
tab_main.pack()
#place(relx=0.02,rely=0.02,relwidth=0.8,relheight=0.8)

tab1 = ttk.Frame(tab_main)
tab1.pack()
tab_main.add(tab1,text='第一页')#将第一页插入分页栏中


button = ttk.Button(tab1,text='1',width=5)
button.pack()
button = ttk.Button(tab1,text='2',width=5)
button.pack()
T1 = tk.Text(tab1)#显示文本框
Example #21
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
import tkinter as tk
import ttkbootstrap as ttk
from random import choice
"""
    Expected Results
    - background is dark
    - only one instance of `BootStyle` or `Tk`
"""

style = ttk.Style(theme="darkly")

root = style.master

root.mainloop()
Example #23
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


def change_style():
    theme = choice(style.theme_names())
    style.theme_use(theme)


if __name__ == '__main__':
    # create visual widget style tests
    root = tk.Tk()
    style = ttk.Style()

    ttk.Button(text="Change Theme", command=change_style).pack(padx=10,
                                                               pady=10)

    test1 = create_frame_test('TFrame', style)
    test1.pack(side=tk.LEFT, fill=tk.BOTH)

    root.mainloop()
Example #24
0
    def __init__(self, isServer: bool = False):
        style = ttk.Style("cosmo")
        self._root = style.master
        self._root.title("FBRecorder")
        self._root.resizable(False, False)
        self._root.protocol("WM_DELETE_WINDOW", self.shutdown)

        self._recv = FBFloatMultiRecv()
        self._recv.registerRecvAllCallback(self.updateData)
        self._client = FBServer() if isServer else FBClient()
        self._client.registerRecvCallback(self._recv.input)

        self._csvWriter: FBCSVWriter = None
        self._cvsWriterLock = threading.Lock()

        self.cnt = 0
        self._cntLock = threading.Lock()
        self._cntVar = tk.StringVar(value="0")

        cfgFrame = ttk.Frame(self._root)
        cfgFrame.pack(padx=5, pady=5)
        self.cfg_path = tk.StringVar()
        self._cfgPathEntry = ttk.Entry(cfgFrame,
                                       textvariable=self.cfg_path,
                                       state="readonly",
                                       width=30)
        self._cfgPathButton = ttk.Button(cfgFrame,
                                         text="选择",
                                         command=self._selectCfgPath)

        ttk.Label(cfgFrame, text="配置文件").pack(side="left")
        self._cfgPathEntry.pack(side="left")
        self._cfgPathButton.pack(side="left")

        saveFrame = ttk.Frame(self._root)
        saveFrame.pack(padx=5, pady=5)
        self.save_path = tk.StringVar()
        self._savePathEntry = ttk.Entry(saveFrame,
                                        textvariable=self.save_path,
                                        state="readonly",
                                        width=30)
        self._savePathButton = ttk.Button(saveFrame,
                                          text="选择",
                                          command=self._selectSavePath)

        ttk.Label(saveFrame, text="保存文件").pack(side="left")
        self._savePathEntry.pack(side="left")
        self._savePathButton.pack(side="left")

        opFrame = ttk.Frame(self._root)
        opFrame.pack(padx=5, pady=5, fill="x", expand=True)
        self._appendsButton = ttk.Checkbutton(
            opFrame,
            text="追加",
            bootstyle=("info", "outline", "toolbutton"),
        )
        self._recordButton = ttk.Checkbutton(opFrame,
                                             text="录制",
                                             command=self._toggleRecord,
                                             bootstyle=("warning", "outline",
                                                        "toolbutton"))
        self._pauseButton = ttk.Checkbutton(opFrame,
                                            text="暂停",
                                            bootstyle=("success", "outline",
                                                       "toolbutton"))

        self._appendsButton.pack(side="left")
        self._recordButton.pack(side="left", padx=5)
        self._pauseButton.pack(side="left")
        ttk.Label(opFrame, text="已接收:").pack(side="left")
        ttk.Label(opFrame, textvariable=self._cntVar).pack(side="left")