Пример #1
0
 def create_upper_menu(self):
     # Uper section
     frame = Frame(self.master, bg='#a0dbd1', bd=4)
     frame.place(relx=0.5,
                 rely=0.1,
                 relwidth=0.75,
                 relheight=0.1,
                 anchor='n')
     # Set curve and figure variable and trace changes
     self.figure_val = StringVar(frame)
     self.create_OptionMenu(self.figure_val, frame, option_figure[0], 0.05,
                            option_figure)
     self.curve_val = IntVar(frame)
     self.create_OptionMenu(self.curve_val, frame, option_curve[0], 0.30,
                            option_curve)
     # Set color button
     color = TkinterCustomButton(master=frame,
                                 height=52,
                                 text="Color",
                                 command=self.color_option)
     color.place(relx=0.55)
     # Set clear button
     clear = TkinterCustomButton(
         master=frame,
         height=52,
         text="Clear",
         command=lambda: self.lower_frame.delete("all"))
     clear.place(relx=0.80)
Пример #2
0
                query_label.bind("<Button-1>", show)
                i += 1

    # Commit Changes
    conn.commit()
    # Close Connection
    conn.close()

#For Scrollbar
def myfunction(event):
    canvas.configure(scrollregion=canvas.bbox("all"), width=root.winfo_width()*.98, height=root.winfo_height()*.74)

# Code to add widgets will go here...
myLabel = Label(root, text="HWY 12 Titles", font=(30,30))
myLabel.place(x=w/2, y=20, anchor=CENTER)
newCar_btn = TkinterCustomButton(text="Add New Vehicle", corner_radius=0, cursor="hand2", command=newVehicle, border_width=1, border_color="black")
newCar_btn.place(x=w-(w/5), y=30, anchor=N)
carSearch = Entry(root)
carSearch.insert(0,"Please type here")
carSearch.place(x=w-(w/4), y=110, height=30)
carSearch_button =  TkinterCustomButton(text="Enter", corner_radius=0, width=50, cursor="hand2", command=forCar, border_width=1, border_color="black")
carSearch_button.place(x=w-(w/8), y=110)

myframe = Frame(root,relief=GROOVE,width=w,height=l,bd=1)
myframe.place(x=0, y=155)

canvas = Canvas(myframe)
frame = Frame(canvas)
myscrollbar = Scrollbar(myframe, orient="vertical", command=canvas.yview)
canvas.configure(yscrollcommand=myscrollbar.set)
Пример #3
0
import tkinter
from tkinter_custom_button import TkinterCustomButton

app = tkinter.Tk()
app.geometry("300x200")
app.title("TkinterCustomButton")


def button_function():
    print("Button pressed")


button_1 = TkinterCustomButton(text="My Button",
                               corner_radius=10,
                               command=button_function)
button_1.place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)

app.mainloop()
Пример #4
0
    def __init__(self, *args, **kwargs):
        if sys.platform == "darwin":  # macOS
            if Version(tkinter.Tcl().call("info", "patchlevel")) >= Version("8.6.9"):  # Tcl/Tk >= 8.6.9
                os.system("defaults write -g NSRequiresAquaSystemAppearance -bool No")  # turn on dark mode for all apps
                # Currently this works only with anaconda python version (python.org Tcl/Tk version is only 8.6.8).

        tkinter.Tk.__init__(self, *args, **kwargs)

        self.minsize(WIDTH, HEIGHT)
        self.resizable(True, True)
        self.title(APP_NAME)
        self.geometry(str(WIDTH) + "x" + str(HEIGHT))

        self.protocol("WM_DELETE_WINDOW", self.on_closing)
        self.bind("<Command-q>", self.on_closing)
        self.bind("<Command-w>", self.on_closing)

        if sys.platform == "darwin":  # macOS
            self.menubar = tkinter.Menu(master=self)
            self.app_menu = tkinter.Menu(self.menubar, name='apple')
            self.menubar.add_cascade(menu=self.app_menu)

            self.app_menu.add_command(label='About ' + APP_NAME, command=self.about_dialog)
            self.app_menu.add_separator()

            self.config(menu=self.menubar)
            self.createcommand('tk::mac::Quit', self.on_closing)

        # ========== slightly rounded corners =============

        self.button_1 = TkinterCustomButton(master=self,
                                            bg_color=None,
                                            fg_color="#2874A6",
                                            hover_color="#5499C7",
                                            text_font=None,
                                            text="Test Button 1",
                                            text_color="white",
                                            corner_radius=10,
                                            width=120,
                                            height=45,
                                            hover=True,
                                            command=self.test_function)
        self.button_1.place(relx=0.33, rely=0.2, anchor=tkinter.CENTER)

        self.button_2 = TkinterCustomButton(master=self,
                                            bg_color=None,
                                            fg_color="#922B21",
                                            border_color="white",
                                            hover_color="#CD6155",
                                            text_font=None,
                                            text="Test Button 2",
                                            text_color="white",
                                            corner_radius=10,
                                            border_width=2,
                                            width=150,
                                            height=45,
                                            hover=True,
                                            command=self.test_function)
        self.button_2.place(relx=0.66, rely=0.2, anchor=tkinter.CENTER)

        # ========== fully rounded corners =============

        self.button_3 = TkinterCustomButton(master=self,
                                            bg_color=None,
                                            fg_color="#1E8449",
                                            hover_color="#2ECC71",
                                            text_font=None,
                                            text="Test Button 3",
                                            text_color="white",
                                            corner_radius=20,
                                            width=120,
                                            height=40,
                                            hover=True,
                                            command=self.test_function)
        self.button_3.place(relx=0.33, rely=0.4, anchor=tkinter.CENTER)

        self.button_4 = TkinterCustomButton(master=self,
                                            bg_color=None,
                                            border_color="#BB8FCE",
                                            fg_color="#6C3483",
                                            hover_color="#A569BD",
                                            text_font=None,
                                            text="Test Button 4",
                                            text_color="white",
                                            corner_radius=20,
                                            border_width=2,
                                            width=150,
                                            height=40,
                                            hover=True,
                                            command=self.test_function)
        self.button_4.place(relx=0.66, rely=0.4, anchor=tkinter.CENTER)

        # ========== no rounded corners =============

        self.button_5 = TkinterCustomButton(master=self,
                                            bg_color=None,
                                            fg_color="#A93226",
                                            hover_color="#CD6155",
                                            text_font=None,
                                            text="Test Button 5",
                                            text_color="black",
                                            corner_radius=0,
                                            width=120,
                                            height=40,
                                            hover=True,
                                            command=self.test_function)
        self.button_5.place(relx=0.33, rely=0.6, anchor=tkinter.CENTER)

        self.button_6 = TkinterCustomButton(master=self,
                                            bg_color=None,
                                            fg_color=self.cget("bg"),
                                            border_color="#ABB2B9",
                                            hover_color="#566573",
                                            text_font=None,
                                            text="Test Button 6",
                                            text_color="#ABB2B9",
                                            corner_radius=0,
                                            border_width=2,
                                            width=120,
                                            height=40,
                                            hover=True,
                                            command=self.test_function)
        self.button_6.place(relx=0.66, rely=0.6, anchor=tkinter.CENTER)

        # ========== other shapes =============

        from PIL import Image, ImageTk

        play_image = ImageTk.PhotoImage(Image.open("button_test_images/play_button_image.png").resize((30, 30)))

        self.button_7 = TkinterCustomButton(master=self,
                                            bg_color=None,
                                            fg_color="#58636F",
                                            border_color=None,
                                            hover_color="#808B96",
                                            image=play_image,  # <- add image (class PhotoImage)
                                            corner_radius=10,
                                            border_width=0,
                                            width=50,
                                            height=50,
                                            hover=True,
                                            command=self.test_function)
        self.button_7.place(relx=0.33, rely=0.8, anchor=tkinter.CENTER)

        self.button_8 = TkinterCustomButton(master=self,
                                            bg_color=None,
                                            fg_color="#212F3D",
                                            border_color="#117A65",
                                            hover_color="#34495E",
                                            text_font=None,
                                            text="Button 8",
                                            text_color="white",
                                            corner_radius=12,
                                            border_width=4,
                                            width=100,
                                            height=60,
                                            hover=True,
                                            command=self.test_function)
        self.button_8.place(relx=0.66, rely=0.8, anchor=tkinter.CENTER)

        self.running = False
Пример #5
0
def roots():
    global urlbutton, roots, paste, mp3low, mp3medium, mp3high, flac, aac, wav, mp4, mkv, webm

    roots = Tk()
    roots.title('YouTube Downloader')
    roots.configure(background='black')
    logo = PhotoImage(file="ytlogo.png")

    labellogo = Label(roots, image=logo, background="black").grid(row=0,
                                                                  columnspan=3,
                                                                  column=0,
                                                                  padx=2,
                                                                  pady=2)
    label = Label(roots,
                  text="Enter URL:",
                  bg="black",
                  fg="white",
                  font='Calibri').grid(row=1,
                                       columnspan=3,
                                       column=0,
                                       padx=2,
                                       pady=5)
    urlbutton = Entry(roots,
                      background="#FAFAFA",
                      foreground="#000000",
                      width=100)
    urlbutton.grid(row=2, columnspan=3, column=0, padx=2, pady=2)
    #grab=Button(roots, text='Paste', command=paste, font='Calibri', height=1).grid(row=2, column=3, padx=2, pady=2)
    grab = TkinterCustomButton(text="Paste",
                               corner_radius=10,
                               command=paste,
                               text_font='Calibri',
                               height=27,
                               fg_color='#4d004d',
                               hover_color='#670067').grid(row=3,
                                                           column=1,
                                                           padx=2,
                                                           pady=15)
    #grab=Button(roots, text='Paste from clipboard', command=paste, bg="black", font='Calibri', fg="white", width=15, corner_radius=10).grid(row=3, column=1, padx=2, pady=2).place(relx=0.5, rely=0.5, anchor=tkinter.CENTER)
    #grab=TkinterCustomButton(text="Paste", corner_radius=10, command=paste, text_font='Calibri').grid(row=3, column=1, padx=2, pady=2)

    mp3low = TkinterCustomButton(text="MP3 96kbps",
                                 corner_radius=10,
                                 command=mp3low,
                                 text_font='Calibri').grid(row=4,
                                                           column=0,
                                                           padx=2,
                                                           pady=7)
    mp3medium = TkinterCustomButton(text="MP3 192kbps",
                                    corner_radius=10,
                                    command=mp3medium,
                                    text_font='Calibri').grid(row=4,
                                                              column=1,
                                                              padx=2,
                                                              pady=7)
    mp3high = TkinterCustomButton(text="MP3 328kbps",
                                  corner_radius=10,
                                  command=mp3high,
                                  text_font='Calibri').grid(row=4,
                                                            column=2,
                                                            padx=2,
                                                            pady=7)

    flac = TkinterCustomButton(text="FLAC",
                               corner_radius=10,
                               command=flac,
                               text_font='Calibri').grid(row=5,
                                                         column=0,
                                                         padx=2,
                                                         pady=7)
    aac = TkinterCustomButton(text="AAC",
                              corner_radius=10,
                              command=aac,
                              text_font='Calibri').grid(row=5,
                                                        column=1,
                                                        padx=2,
                                                        pady=7)
    wav = TkinterCustomButton(text="WAV",
                              corner_radius=10,
                              command=wav,
                              text_font='Calibri').grid(row=5,
                                                        column=2,
                                                        padx=2,
                                                        pady=7)

    mp4 = TkinterCustomButton(text="MP4",
                              corner_radius=10,
                              command=mp4,
                              text_font='Calibri').grid(row=6,
                                                        column=0,
                                                        padx=2,
                                                        pady=7)
    mkv = TkinterCustomButton(text="MKV",
                              corner_radius=10,
                              command=mkv,
                              text_font='Calibri').grid(row=6,
                                                        column=1,
                                                        padx=2,
                                                        pady=7)
    webm = TkinterCustomButton(text="WEBM",
                               corner_radius=10,
                               command=webm,
                               text_font='Calibri').grid(row=6,
                                                         column=2,
                                                         padx=2,
                                                         pady=7)

    label = Label(roots, text=" " * 100, bg="black",
                  font=("Calibri", 12)).grid(row=7,
                                             columnspan=3,
                                             column=0,
                                             padx=2,
                                             pady=7)
    roots.mainloop()
import tkinter
from tkinter_custom_button import TkinterCustomButton
from PIL import Image, ImageTk

app = tkinter.Tk()
app.geometry("300x200")
app.title("TkinterCustomButton")

def button_function():
    print("Button pressed")

play_image = ImageTk.PhotoImage(Image.open("button_test_images/play_button_image.png").resize((40, 40)))
skip_image = ImageTk.PhotoImage(Image.open("button_test_images/skip_button_image.png").resize((40, 40)))

button_1 = TkinterCustomButton(image=play_image, width=60, height=60, corner_radius=12, command=button_function)
button_1.place(relx=0.33, rely=0.5, anchor=tkinter.CENTER)

button_2 = TkinterCustomButton(image=skip_image, width=60, height=60, corner_radius=12, command=button_function)
button_2.place(relx=0.66, rely=0.5, anchor=tkinter.CENTER)

app.mainloop()
Пример #7
0
    def create_upper_menu(self):
        # Uper section 1
        frame = Frame(self.master, bg='#a0dbd1', bd=4)
        frame.place(relx=0.5,
                    rely=0.04,
                    relwidth=0.80,
                    relheight=0.1,
                    anchor='n')
        # Open jason file
        openfile = TkinterCustomButton(master=frame,
                                       height=52,
                                       text="Open File",
                                       command=self.openfile)
        openfile.place(relx=0)
        # Derivative
        derivative = TkinterCustomButton(master=frame,
                                         height=52,
                                         text="cutting",
                                         command=self.derived)
        derivative.place(relx=0.20)
        # Reset by defult/user file if he upload file
        reset = TkinterCustomButton(master=frame,
                                    height=52,
                                    text="Reset",
                                    command=self.reset)
        reset.place(relx=0.40)
        # Help give the option to open help file to get all information abount function
        helps = TkinterCustomButton(master=frame,
                                    height=52,
                                    text="Help",
                                    command=self.helpf)
        helps.place(relx=0.60)
        rotate = TkinterCustomButton(master=frame,
                                     height=52,
                                     text="rotate",
                                     command=self.rotate)
        rotate.place(relx=0.80)

        # Uper section 2
        frame2 = Frame(self.master, bg='#a0dbd1', bd=4)
        frame2.place(relx=0.5,
                     rely=0.15,
                     relwidth=0.8,
                     relheight=0.1,
                     anchor='n')
        # Move to current position
        move = TkinterCustomButton(master=frame2,
                                   height=52,
                                   text="Move",
                                   command=self.move)
        move.place(relx=0)
        # zoomIn
        zoomIn = TkinterCustomButton(master=frame2,
                                     height=52,
                                     text="zoomIn +",
                                     command=self.zoomIn)
        zoomIn.place(relx=0)
        # zoomOut
        zoomOut = TkinterCustomButton(master=frame2,
                                      height=52,
                                      text="zoomOut -",
                                      command=self.zoomOut)
        zoomOut.place(relx=0.20)
        MirorX = TkinterCustomButton(master=frame2,
                                     height=52,
                                     text="Miror to X",
                                     command=self.mirrorX)
        MirorX.place(relx=0.40)
        MirorY = TkinterCustomButton(master=frame2,
                                     height=52,
                                     text="Miror to Y",
                                     command=self.mirrory)
        MirorY.place(relx=0.60)
        MirrorXY = TkinterCustomButton(master=frame2,
                                       height=52,
                                       text="Miror to XY",
                                       command=self.mirrorXY)
        MirrorXY.place(relx=0.80)
Пример #8
0
def gui():
    master = tkinter.Tk()
    ctypes.windll.shcore.SetProcessDpiAwareness(1)
    perfpath = tkinter.StringVar()
    smartpath = tkinter.StringVar()
    tcpath = tkinter.StringVar()
    pcpath = tkinter.StringVar()
    master.title('Chart GUI')
    width = 970
    height = 700
    screenwidth = master.winfo_screenwidth()
    screenheight = master.winfo_screenheight()
    x = (screenwidth / 2) - (width / 2)
    y = (screenheight / 2) - (height / 2)
    master.geometry("%dx%d+%d+%d" % (width, height, x, y))
    master.configure(background='#303E4F')

    def quit_on_click():
        master.quit()
        master.destroy()
        sys.exit()

    def perf_file():
        f = filedialog.askopenfilename(
            initialdir="/Desktop",
            title="Select A File",
            filetypes=(("Comma Separated Values File", "*.csv"), ("All Files",
                                                                  "*.*")))
        perfpathE.delete(0, tkinter.END)
        perfpathE.insert(0, f)
        return

    def smart_file():
        f = filedialog.askopenfilename(
            initialdir="/Desktop",
            title="Select A File",
            filetypes=(("Comma Separated Values File", "*.csv"), ("All Files",
                                                                  "*.*")))
        smartpathE.delete(0, tkinter.END)
        smartpathE.insert(0, f)
        return

    def tc_file():
        f = filedialog.askopenfilename(
            initialdir="/Desktop",
            title="Select A File",
            filetypes=(("Comma Separated Values File", "*.csv"), ("All Files",
                                                                  "*.*")))
        tcpathE.delete(0, tkinter.END)
        tcpathE.insert(0, f)
        return

    def pc_file():
        f = filedialog.askopenfilename(
            initialdir="/Desktop",
            title="Select A File",
            filetypes=(("Comma Separated Values File", "*.csv"), ("All Files",
                                                                  "*.*")))
        pcpathE.delete(0, tkinter.END)
        pcpathE.insert(0, f)
        return

    def clearall():
        opt.delete(0, tkinter.END)
        voltage.delete(0, tkinter.END)
        channel.delete(0, tkinter.END)
        perfpathE.delete(0, tkinter.END)
        smartpathE.delete(0, tkinter.END)
        tcpathE.delete(0, tkinter.END)
        pcpathE.delete(0, tkinter.END)
        return

    def submitall():
        if str(opt.get()) == '':
            opt.set('Sequential')
            return

        if voltage.get() == '':
            defval = 3.3
            voltage.set(defval)

        if channel.get() == '':
            defval = 101
            channel.set(defval)

        fperfpath = str(perfpathE.get())
        fsmartpath = str(smartpathE.get())
        ftcpath = str(tcpathE.get())
        fpcpath = str(pcpathE.get())
        fchannel = int(channel.get())
        fvoltage = float(voltage.get())

        print('perfpath is:', fperfpath)
        print('smartpath is:', fsmartpath)
        print('tcpath is:', ftcpath)
        print('pcpath is:', fpcpath)
        print('channel is:', fchannel)
        print('voltage is:', fvoltage)

        import combineChart
        combineChart.main(str(opt.get()), str(fperfpath), str(fsmartpath),
                          str(ftcpath), str(fpcpath), int(fchannel),
                          float(fvoltage))

    ttk.Label(master,
              background='#303E4F',
              foreground='#ffffff',
              text="Select Data Type:",
              font=("Calibri Light", 12)).place(x=50, y=50)
    n = tkinter.StringVar()
    opt = ttk.Combobox(master,
                       width=27,
                       textvariable=n,
                       values=('Sequential', 'Random'))
    opt.place(x=200, y=50)
    opt.current()

    ttk.Label(master,
              background='#303E4F',
              foreground='#ffffff',
              text="Select Voltage:",
              font=("Calibri Light", 12)).place(x=500, y=50)
    q = tkinter.StringVar()
    voltage = ttk.Combobox(master, width=27, textvariable=q)
    voltage['values'] = (3.3, 5, 12)
    voltage.place(x=650, y=50)
    voltage.current()

    ttk.Label(master,
              background='#303E4F',
              foreground='#ffffff',
              text="Channel Used:",
              font=("Calibri Light", 12)).place(x=130, y=385)
    ch = tkinter.StringVar()
    channel = ttk.Combobox(master, width=27, textvariable=ch)
    channel['values'] = (101, 102, 103, 104, 105, 106, 107, 108, 109, 110, 111,
                         112, 113, 114, 115, 116, 117, 118, 119, 120, 121, 122,
                         123, 124, 125)
    channel.place(x=275, y=385)
    channel.current()

    TkinterCustomButton(master=master,
                        bg_color=None,
                        fg_color='#303E4F',
                        border_color="#f57567",
                        text_font=None,
                        text="Performance Data",
                        text_color="#f57567",
                        corner_radius=0,
                        border_width=2,
                        width=200,
                        height=50,
                        hover=False,
                        command=perf_file).place(x=50, y=120)

    TkinterCustomButton(master=master,
                        bg_color=None,
                        fg_color='#303E4F',
                        border_color="#d28aff",
                        text_font=None,
                        text="SMART Temp Data",
                        text_color="#d28aff",
                        corner_radius=0,
                        border_width=2,
                        width=200,
                        height=50,
                        hover=False,
                        command=smart_file).place(x=50, y=220)

    TkinterCustomButton(master=master,
                        bg_color=None,
                        fg_color='#303E4F',
                        border_color="#ffffb0",
                        text_font=None,
                        text="Thermal Coup. Data",
                        text_color="#ffffb0",
                        corner_radius=0,
                        border_width=2,
                        width=200,
                        height=50,
                        hover=False,
                        command=tc_file).place(x=50, y=320)

    TkinterCustomButton(master=master,
                        bg_color=None,
                        fg_color='#303E4F',
                        border_color="#9efdff",
                        text_font=("Century Gothic", 9),
                        text="Power Consumption Data",
                        text_color="#9efdff",
                        corner_radius=0,
                        border_width=2,
                        width=200,
                        height=50,
                        hover=False,
                        command=pc_file).place(x=50, y=460)

    TkinterCustomButton(master=master,
                        bg_color=None,
                        fg_color='#303E4F',
                        border_color="#ff61e9",
                        text="Submit",
                        text_color="#ff61e9",
                        corner_radius=0,
                        border_width=2,
                        width=200,
                        height=50,
                        hover=False,
                        command=submitall).place(x=275, y=560)

    TkinterCustomButton(master=master,
                        bg_color=None,
                        fg_color='#303E4F',
                        border_color="#fdbdff",
                        text="Clear All",
                        text_color="#fdbdff",
                        corner_radius=0,
                        border_width=2,
                        width=200,
                        height=50,
                        hover=False,
                        command=clearall).place(x=500, y=560)

    perfpathE = ttk.Entry(master, width=76, textvariable=perfpath)
    perfpathE.place(x=275, y=130)

    smartpathE = ttk.Entry(master, width=75, textvariable=smartpath)
    smartpathE.place(x=275, y=230)

    tcpathE = ttk.Entry(master, width=75, textvariable=tcpath)
    tcpathE.place(x=275, y=330)

    pcpathE = ttk.Entry(master, width=75, textvariable=pcpath)
    pcpathE.place(x=275, y=470)

    master.protocol("WM_DELETE_WINDOW", quit_on_click)
    master.mainloop()