コード例 #1
0
ファイル: TicketQuery.py プロジェクト: azz212/TKinterDesigner
 def __init__(self, root, isTKroot=True):
     className = self.__class__.__name__
     Fun.G_UIElementArray[className] = {}
     Fun.G_UIElementUserDataArray[className] = {}
     Fun.Register(className, 'UIClass', self)
     self.root = root
     style = TicketQuery_sty.SetupStyle()
     if isTKroot == True:
         root.title("Form1")
         Fun.CenterDlg(None, root, 721, 400)
     Form_1 = tkinter.Canvas(root, width=10, height=4)
     Form_1.place(x=0, y=0, width=721, height=400)
     Form_1.configure(bg="#efefef")
     Form_1.configure(highlightthickness=0)
     Fun.Register(className, 'root', root)
     Fun.Register(className, 'Form_1', Form_1)
     #Create the elements of root
     Label_2 = tkinter.Label(root, text="出发", width=10, height=4)
     Label_2.place(x=13, y=25, width=44, height=37)
     Label_2.configure(relief="flat")
     Label_2_Ft = tkinter.font.Font(family='System',
                                    size=12,
                                    weight='bold',
                                    slant='roman',
                                    underline=0,
                                    overstrike=0)
     Label_2.configure(font=Label_2_Ft)
     Fun.Register(className, 'Label_2', Label_2)
     Entry_3_Variable = Fun.AddTKVariable(className, 'Entry_3', '')
     Entry_3 = tkinter.Entry(root, textvariable=Entry_3_Variable)
     Entry_3.place(x=65, y=26, width=120, height=37)
     Entry_3.configure(relief="sunken")
     Fun.Register(className, 'Entry_3', Entry_3)
     Label_4 = tkinter.Label(root, text="到达", width=10, height=4)
     Label_4.place(x=193, y=32, width=46, height=28)
     Label_4.configure(relief="flat")
     Label_4_Ft = tkinter.font.Font(family='System',
                                    size=12,
                                    weight='bold',
                                    slant='roman',
                                    underline=0,
                                    overstrike=0)
     Label_4.configure(font=Label_4_Ft)
     Fun.Register(className, 'Label_4', Label_4)
     Entry_5_Variable = Fun.AddTKVariable(className, 'Entry_5', '')
     Entry_5 = tkinter.Entry(root, textvariable=Entry_5_Variable)
     Entry_5.place(x=242, y=26, width=120, height=37)
     Entry_5.configure(relief="sunken")
     Fun.Register(className, 'Entry_5', Entry_5)
     Label_6 = tkinter.Label(root, text="日期", width=10, height=4)
     Label_6.place(x=364, y=28, width=56, height=35)
     Label_6.configure(relief="flat")
     Label_6_Ft = tkinter.font.Font(family='System',
                                    size=12,
                                    weight='bold',
                                    slant='roman',
                                    underline=0,
                                    overstrike=0)
     Label_6.configure(font=Label_6_Ft)
     Fun.Register(className, 'Label_6', Label_6)
     Entry_8_Variable = Fun.AddTKVariable(className, 'Entry_8', '')
     Entry_8 = tkinter.Entry(root, textvariable=Entry_8_Variable)
     Entry_8.place(x=422, y=26, width=140, height=37)
     Entry_8.configure(relief="sunken")
     Fun.Register(className, 'Entry_8', Entry_8)
     Button_9 = tkinter.Button(root, text="查询", width=10, height=4)
     Button_9.place(x=568, y=23, width=119, height=43)
     Button_9.configure(command=lambda: TicketQuery_cmd.Button_9_onCommand(
         className, "Button_9"))
     Button_9_Ft = tkinter.font.Font(family='System',
                                     size=12,
                                     weight='bold',
                                     slant='roman',
                                     underline=0,
                                     overstrike=0)
     Button_9.configure(font=Button_9_Ft)
     Fun.Register(className, 'Button_9', Button_9)
     ListBox_10 = tkinter.Listbox(root)
     ListBox_10.place(x=13, y=74, width=690, height=309)
     Fun.Register(className, 'ListBox_10', ListBox_10)
     #Inital all element's Data
     Fun.InitElementData(className)
     #Call Form_1's OnLoad Function
     TicketQuery_cmd.Form_1_onLoad(className)
コード例 #2
0
    def __init__(self):
        win = tkinter.Tk()
        win.title("Reservation Record")
        win.resizable(0, 0)

        datetime_label = tkinter.Label(win,
                                       font=('Arial bold', 12),
                                       text="Record").grid(column=0, row=0)

        datetime_listbox = tkinter.Listbox(win,
                                           font=('Arial bold', 12),
                                           width=60)
        datetime_listbox.grid(column=0, row=2)

        yscroll = tkinter.Scrollbar(win,
                                    command=datetime_listbox.yview,
                                    orient=tkinter.VERTICAL)
        yscroll.grid(column=3, row=2, sticky='ENS')
        datetime_listbox.configure(yscrollcommand=yscroll.set)

        i = -1  #for inserting elements
        datetime_list = []
        for file in sorted(os.listdir(config.path)):
            if fnmatch.fnmatch(file, '*record*'):
                datetime_list.insert(i + 1, file)  #list elements
        for t in datetime_list:
            datetime_listbox.insert(0, t)

        def onclick():
            file = config.path + datetime_listbox.get(
                datetime_listbox.curselection())
            f = open(file, "r")
            record_list = []
            record_lines = f.readlines()
            for line in record_lines:
                record_list.append(line)
            record = '\n'.join(record_list)
            x = win.winfo_x()
            y = win.winfo_y()
            top = tkinter.Toplevel(win)
            top.geometry("+%d+%d" % (x + 200, y + 100))
            top.wm_attributes("-topmost", 1)
            top_button = tkinter.Button(top,
                                        font=('Arial bold', 12),
                                        text=record,
                                        command=top.destroy).grid()

        def onclick_delete():
            msg = tkinter.messagebox.askyesno("Warning",
                                              "Delete the Reservation?")
            if msg == tkinter.YES:
                file = config.path + datetime_listbox.get(
                    datetime_listbox.curselection())
                os.remove(file)
                time.sleep(0.2)
                datetime_listbox.delete(datetime_listbox.curselection())
                tkinter.messagebox.showinfo(title="Success",
                                            message="Record Deleted!")

        check_button = tkinter.Button(win,
                                      font=('Arial bold', 12),
                                      text="Check Details",
                                      command=onclick).grid(row=3,
                                                            column=0,
                                                            padx=30)
        delete_button = tkinter.Button(win,
                                       font=('Arial bold', 12),
                                       text="Delete",
                                       command=onclick_delete).grid(row=4,
                                                                    column=0,
                                                                    padx=30)

        explanation_label = tkinter.Label(
            win,
            font=('Arial bold', 12),
            text=
            "Please select a record and click ''Check/Delete'' to check/delete the booking record's information.",
            justify=tkinter.CENTER)
        explanation_label.grid(row=5)

        win.wm_attributes("-topmost", 1)

        win.mainloop()
コード例 #3
0
def auth_and_pick_sites(auth_method, username, password, auth_token,
                        parent_window):
    ###AUTH_METHOD, 1 = API_TOKEN, 2 = UN/PW
    global win_jinjatool_main, chk_selectcommon, chk_selectnames, chk_selectpolicybindings
    global chk_selectinterfaces
    global input_frame, options_frame, operation_frame, output_frame
    global lst_Listbox_data

    import cloudgenix_config
    from cloudgenix_config import pull
    global sdk

    if (auth_method == 1):  ###API TOKEN AUTH
        try:
            auth_status = sdk.interactive.use_token(auth_token)
        except:
            auth_status = False
    else:
        auth_status = sdk.interactive.login(email=username, password=password)
        try:
            auth_status
        except:
            auth_status = False

    if auth_status:
        site_list = sdk.get.sites().cgx_content.get("items")

        win_site_picker = tk.Toplevel()
        win_site_picker.title('Please Select your Site')

        lbl_1 = tk.Label(win_site_picker, text="Choose One Site Below:")
        lbl_1.pack(side="left", expand=1, pady=5, fill="y")

        lst_Listbox_sites = tk.Listbox(win_site_picker)
        site_list_scrollbar = tk.Scrollbar(win_site_picker)
        lst_Listbox_sites.config(yscrollcommand=site_list_scrollbar.set)
        site_list_scrollbar.config(command=lst_Listbox_sites.yview)

        site_list_scrollbar.pack(side="right", fill="y")
        lst_Listbox_sites.pack(expand=1, fill="both", side="left")

        btn_ok_sites = tk.Button(
            win_site_picker,
            text="OK",
            command=lambda: load_site([win_site_picker, parent_window], sdk,
                                      lst_Listbox_sites, site_list))
        btn_cancel_sites = tk.Button(
            win_site_picker,
            text="CANCEL",
            command=lambda: kill_windows(win_site_picker))

        btn_cancel_sites.pack(side="right", expand=1, pady=5, padx=10)
        btn_ok_sites.pack(side="left", expand=1, pady=5)

        win_site_picker.lift(aboveThis=parent_window)
        win_site_picker.grab_set()

        for site in site_list:
            lst_Listbox_sites.insert(END, str(site['name']))
    else:
        alert("Authentication Failed, please verify your credentials", "Error")
コード例 #4
0
    def __init__(self, master, path):
        self.master = master
        master.title("CIF to STL")
        self.cifInfoTable = []
        framebg = "white"
        labelbg = "white"
        buttonbg = "white"

        framepadx = 10
        framepady = 5

        #Bonds
        self.bondsList = []

        #Atom Positions
        self.atomPositionTable = []

        #File Path Box
        self.file_path_text = tkinter.StringVar()
        self.fileFrame = tkinter.LabelFrame(master,
                                            text='Load CIF',
                                            padx=5,
                                            pady=5,
                                            bg=framebg)

        self.file_path = tkinter.Entry(self.fileFrame)
        #Go to Path Button
        self.load_button = tkinter.Button(self.fileFrame,
                                          text="Load",
                                          command=lambda: self.loadCif(),
                                          bg=buttonbg)
        self.run_button = tkinter.Button(self.fileFrame,
                                         text="Run",
                                         command=lambda: self.buildModel(),
                                         bg=buttonbg)

        #Cell Parameter Info
        self.cellLabelFrame = tkinter.LabelFrame(master,
                                                 text='Cell Parameters',
                                                 bg=framebg)
        self.cellParamLabel_a = tkinter.Label(self.cellLabelFrame,
                                              text="a:",
                                              bg=labelbg)
        self.cellParamLabel_b = tkinter.Label(self.cellLabelFrame,
                                              text="b:",
                                              bg=labelbg)
        self.cellParamLabel_c = tkinter.Label(self.cellLabelFrame,
                                              text="c:",
                                              bg=labelbg)
        self.cellParamLabel_alpha = tkinter.Label(self.cellLabelFrame,
                                                  text="alpha:",
                                                  bg=labelbg)
        self.cellParamLabel_beta = tkinter.Label(self.cellLabelFrame,
                                                 text="beta:",
                                                 bg=labelbg)
        self.cellParamLabel_gamma = tkinter.Label(self.cellLabelFrame,
                                                  text="gamma:",
                                                  bg=labelbg)
        self.cellParamLabel_volume = tkinter.Label(self.cellLabelFrame,
                                                   text="volume:",
                                                   bg=labelbg)

        self.cellParamEntry_a = tkinter.Entry(self.cellLabelFrame)
        self.cellParamEntry_b = tkinter.Entry(self.cellLabelFrame)
        self.cellParamEntry_c = tkinter.Entry(self.cellLabelFrame)
        self.cellParamEntry_alpha = tkinter.Entry(self.cellLabelFrame)
        self.cellParamEntry_beta = tkinter.Entry(self.cellLabelFrame)
        self.cellParamEntry_gamma = tkinter.Entry(self.cellLabelFrame)
        self.cellParamEntry_volume = tkinter.Entry(self.cellLabelFrame)

        self.cellParamEntryText_a = tkinter.StringVar()
        self.cellParamEntryText_b = tkinter.StringVar()
        self.cellParamEntryText_c = tkinter.StringVar()
        self.cellParamEntryText_alpha = tkinter.StringVar()
        self.cellParamEntryText_beta = tkinter.StringVar()
        self.cellParamEntryText_gamma = tkinter.StringVar()
        self.cellParamEntryText_volume = tkinter.StringVar()

        #Model Parameters
        self.modelParametersFrame = tkinter.LabelFrame(master,
                                                       text='Model Parameters',
                                                       padx=5,
                                                       pady=5,
                                                       bg=framebg)

        self.modelScaler = tkinter.Label(self.modelParametersFrame,
                                         text="Scaler:",
                                         bg=labelbg)
        self.modelScalerEntry = tkinter.Entry(self.modelParametersFrame)
        self.modelScalerEntryText = tkinter.StringVar()

        self.modelScalerEntryText.set("1")
        self.modelScalerEntry.insert(0, self.modelScalerEntryText.get())

        self.modelSphereSize = tkinter.Label(self.modelParametersFrame,
                                             text="Sphere Size:",
                                             bg=labelbg)
        self.modelSphereSizeEntry = tkinter.Entry(self.modelParametersFrame)
        self.modelSphereSizeEntryText = tkinter.StringVar()
        self.modelSphereSizeEntryText.set("0.1")
        self.modelSphereSizeEntry.insert(0,
                                         self.modelSphereSizeEntryText.get())
        self.modelBondWidth = tkinter.Label(self.modelParametersFrame,
                                            text="Bond Width:",
                                            bg=labelbg)
        self.modelBondWidthEntry = tkinter.Entry(self.modelParametersFrame)
        self.modelBondWidthEntryText = tkinter.StringVar()
        self.modelBondWidthEntryText.set("0.1")
        self.modelBondWidthEntry.insert(0, self.modelBondWidthEntryText.get())
        self.bondsOnVar = tkinter.IntVar()

        self.modelBoundariesFrame = tkinter.LabelFrame(master,
                                                       text='Model Boundaries',
                                                       padx=5,
                                                       pady=5,
                                                       bg=framebg)

        self.modelXMax = tkinter.Label(self.modelBoundariesFrame,
                                       text="x(max):",
                                       bg=labelbg)
        self.modelXMaxEntry = tkinter.Entry(self.modelBoundariesFrame)
        self.modelXMaxEntryText = tkinter.StringVar()
        self.modelXMaxEntryText.set("1")
        self.modelXMaxEntry.insert(0, self.modelXMaxEntryText.get())
        self.modelXMin = tkinter.Label(self.modelBoundariesFrame,
                                       text="x(min):",
                                       bg=labelbg)
        self.modelXMinEntry = tkinter.Entry(self.modelBoundariesFrame)
        self.modelXMinEntryText = tkinter.StringVar()
        self.modelXMinEntryText.set("0")
        self.modelXMinEntry.insert(0, self.modelXMinEntryText.get())

        self.modelYMax = tkinter.Label(self.modelBoundariesFrame,
                                       text="y(max):",
                                       bg=labelbg)
        self.modelYMaxEntry = tkinter.Entry(self.modelBoundariesFrame)
        self.modelYMaxEntryText = tkinter.StringVar()
        self.modelYMaxEntryText.set("1")
        self.modelYMaxEntry.insert(0, self.modelYMaxEntryText.get())
        self.modelYMin = tkinter.Label(self.modelBoundariesFrame,
                                       text="y(min):",
                                       bg=labelbg)
        self.modelYMinEntry = tkinter.Entry(self.modelBoundariesFrame)
        self.modelYMinEntryText = tkinter.StringVar()
        self.modelYMinEntryText.set("0")
        self.modelYMinEntry.insert(0, self.modelYMinEntryText.get())

        self.modelZMax = tkinter.Label(self.modelBoundariesFrame,
                                       text="z(max):",
                                       bg=labelbg)
        self.modelZMaxEntry = tkinter.Entry(self.modelBoundariesFrame)
        self.modelZMaxEntryText = tkinter.StringVar()
        self.modelZMaxEntryText.set("1")
        self.modelZMaxEntry.insert(0, self.modelZMaxEntryText.get())
        self.modelZMin = tkinter.Label(self.modelBoundariesFrame,
                                       text="z(min):",
                                       bg=labelbg)
        self.modelZMinEntry = tkinter.Entry(self.modelBoundariesFrame)
        self.modelZMinEntryText = tkinter.StringVar()
        self.modelZMinEntryText.set("0")
        self.modelZMinEntry.insert(0, self.modelZMinEntryText.get())

        #Atom List
        self.atomListFrame = tkinter.LabelFrame(master,
                                                text='Atom Positions',
                                                padx=5,
                                                pady=5,
                                                bg=framebg)
        self.atomLabelHead = tkinter.Label(self.atomListFrame,
                                           text="Atom",
                                           bg=labelbg)
        self.atomXLabelHead = tkinter.Label(self.atomListFrame,
                                            text="x",
                                            bg=labelbg)
        self.atomYLabelHead = tkinter.Label(self.atomListFrame,
                                            text="y",
                                            bg=labelbg)
        self.atomZLabelHead = tkinter.Label(self.atomListFrame,
                                            text="z",
                                            bg=labelbg)

        self.atomLabel = tkinter.Listbox(self.atomListFrame,
                                         selectmode=tkinter.SINGLE)
        self.atomXLabel = tkinter.Listbox(self.atomListFrame,
                                          selectmode=tkinter.SINGLE)
        self.atomYLabel = tkinter.Listbox(self.atomListFrame,
                                          selectmode=tkinter.SINGLE)
        self.atomZLabel = tkinter.Listbox(self.atomListFrame,
                                          selectmode=tkinter.SINGLE)

        #Bonds
        self.bondsFrame = tkinter.LabelFrame(master,
                                             text='Bonds',
                                             padx=5,
                                             pady=5,
                                             bg=framebg)
        self.addBondsFrame = tkinter.LabelFrame(self.bondsFrame,
                                                text='Add Bonds',
                                                padx=5,
                                                pady=5,
                                                bg=framebg)

        self.modelBondsOnCheck = tkinter.Checkbutton(self.addBondsFrame,
                                                     text="Bonds",
                                                     variable=self.bondsOnVar,
                                                     bg=labelbg)

        self.bondAtom1Label = tkinter.Label(self.addBondsFrame,
                                            text="Atom 1:",
                                            bg=labelbg)
        self.bondAtom2Label = tkinter.Label(self.addBondsFrame,
                                            text="Atom 2:",
                                            bg=labelbg)
        self.bondAtom1Entry = tkinter.Entry(self.addBondsFrame)
        self.bondAtom1Text = tkinter.StringVar()
        self.bondAtom2Entry = tkinter.Entry(self.addBondsFrame)
        self.bondAtom2Text = tkinter.StringVar()

        self.bondAtomDisLabel = tkinter.Label(self.addBondsFrame,
                                              text="Distance:",
                                              bg=labelbg)
        self.bondAtomDisEntry = tkinter.Entry(self.addBondsFrame)
        self.bondAtomDisText = tkinter.StringVar()

        self.bondAddButton = tkinter.Button(self.addBondsFrame,
                                            text="add",
                                            command=lambda: self.addBond(),
                                            bg=buttonbg)

        self.bondLabelList = tkinter.Listbox(self.bondsFrame,
                                             selectmode=tkinter.SINGLE)
        self.bondLabelList.bind("<Double-1>", self.deleteBondItem)

        #Layout

        self.fileFrame.grid(
            row=0,
            column=0,
            sticky="W,E,N,S",
            padx=framepadx,
            pady=framepady,
        )
        self.load_button.grid(row=0, column=0)
        self.file_path.grid(row=0, column=1, columnspan=4, sticky="W,E,N,S")
        self.run_button.grid(row=0, column=5)

        self.cellLabelFrame.grid(row=1,
                                 column=0,
                                 sticky="W,E,N,S",
                                 padx=framepadx,
                                 pady=framepady)

        self.cellParamLabel_a.grid(row=0, column=0, sticky="E")
        self.cellParamEntry_a.grid(row=0, column=1)

        self.cellParamLabel_b.grid(row=0, column=2, sticky="E")
        self.cellParamEntry_b.grid(row=0, column=3)

        self.cellParamLabel_c.grid(row=0, column=4, sticky="E")
        self.cellParamEntry_c.grid(row=0, column=5)

        self.cellParamLabel_alpha.grid(row=1, column=0, sticky="E")
        self.cellParamEntry_alpha.grid(row=1, column=1)

        self.cellParamLabel_beta.grid(row=1, column=2, sticky="E")
        self.cellParamEntry_beta.grid(row=1, column=3)

        self.cellParamLabel_gamma.grid(row=1, column=4, sticky="E")
        self.cellParamEntry_gamma.grid(row=1, column=5)

        self.cellParamLabel_volume.grid(row=2, column=0, sticky="E")
        self.cellParamEntry_volume.grid(row=2, column=1)

        self.modelParametersFrame.grid(row=2,
                                       column=0,
                                       sticky="W,E,N,S",
                                       padx=framepadx,
                                       pady=framepady)
        self.modelScaler.grid(row=0, column=0, sticky="E")
        self.modelScalerEntry.grid(row=0, column=1)

        self.modelSphereSize.grid(row=1, column=0, sticky="E")
        self.modelSphereSizeEntry.grid(row=1, column=1)

        self.modelBondWidth.grid(row=1, column=2, sticky="E")
        self.modelBondWidthEntry.grid(row=1, column=3)

        self.modelBoundariesFrame.grid(row=3,
                                       column=0,
                                       sticky="W,E,N,S",
                                       padx=framepadx,
                                       pady=framepady)
        self.modelXMax.grid(row=0, column=0, sticky="E")
        self.modelXMaxEntry.grid(row=0, column=1)
        self.modelXMin.grid(row=0, column=2, sticky="E")
        self.modelXMinEntry.grid(row=0, column=3)

        self.modelYMax.grid(row=1, column=0, sticky="E")
        self.modelYMaxEntry.grid(row=1, column=1)
        self.modelYMin.grid(row=1, column=2, sticky="E")
        self.modelYMinEntry.grid(row=1, column=3)

        self.modelZMax.grid(row=2, column=0, sticky="E")
        self.modelZMaxEntry.grid(row=2, column=1)
        self.modelZMin.grid(row=2, column=2, sticky="E")
        self.modelZMinEntry.grid(row=2, column=3)

        self.atomListFrame.grid(row=4,
                                column=0,
                                sticky="W,E,N,S",
                                padx=framepadx,
                                pady=framepady)
        self.atomLabelHead.grid(row=0, column=0)
        self.atomXLabelHead.grid(row=0, column=1)
        self.atomYLabelHead.grid(row=0, column=2)
        self.atomZLabelHead.grid(row=0, column=3)

        self.atomLabel.grid(row=1, column=0)
        self.atomXLabel.grid(row=1, column=1)
        self.atomYLabel.grid(row=1, column=2)
        self.atomZLabel.grid(row=1, column=3)

        self.bondsFrame.grid(row=5,
                             column=0,
                             sticky="W,E,N,S",
                             padx=framepadx,
                             pady=framepady)
        self.addBondsFrame.grid(row=0, column=0, sticky="W")
        self.modelBondsOnCheck.grid(row=0, column=0)

        self.bondAtom1Label.grid(row=1, column=0, sticky="E")
        self.bondAtom1Entry.grid(row=1, column=1)

        self.bondAtom2Label.grid(row=2, column=0, sticky="E")
        self.bondAtom2Entry.grid(row=2, column=1)

        self.bondAtomDisLabel.grid(row=3, column=0, sticky="E")
        self.bondAtomDisEntry.grid(row=3, column=1)
        self.bondAddButton.grid(row=4,
                                column=0,
                                columnspan=2,
                                sticky="W,E,N,S")
        self.bondLabelList.grid(row=0, column=2, sticky="W,E,N,S")
コード例 #5
0
# Ventana de calibracion
tkinter.Label(fC, text="Calibracion").grid(row=0, column=0)
ventanaCalib = tkinter.Text(
    fC,
    width=60,
    height=2,
)
ventanaCalib.grid(row=1, column=0)
tkinter.Button(fcButton, text="Guardar", command=guardar).grid(row=0, column=0)
tkinter.Button(fcButton, text="Copiar", command=copiar).grid(row=0, column=1)
fcButton.grid(row=2, column=0)

# Lista de dispositivos Bluetooth
tkinter.Label(fBD, text="Dispositivos").grid(row=0, column=0)
bluetothList = tkinter.Listbox(fBD,
                               selectmode=tkinter.SINGLE,
                               exportselection=0,
                               width=40)
bluetothList.bind('<<ListboxSelect>>', blueSelect)
bluetothList.grid(row=1, column=0)

# Botones de lista bluettoth
tkinter.Button(fBDButton, text="Buscar", command=blueSearch).grid(row=0,
                                                                  column=0)
tkinter.Button(fBDButton,
               text="Cerrar puerto",
               command=lambda: ventana.serial.close()).grid(row=0, column=1)
fBDButton.grid(row=2, column=0)

# Definicion de geometria

fBD.pack(side=tkinter.LEFT)
コード例 #6
0
    def constant(self) :
        #---------------------------------------------------------------------
        # toplevel
        #---------------------------------------------------------------------
        top = tk.Toplevel()
        top.protocol('WM_DELETE_WINDOW', self.__constant_cancel)
        self.__Component["constant_top"] = top
        #---------------------------------------------------------------------
        # basic frames
        #---------------------------------------------------------------------
        tf = tk.Frame(top, bd=3, relief="groove")
        tf.pack(side="top", fill="x", expand=True)
        mf = tk.Frame(top, bd=3, relief="flat")
        mf.pack(side="top", fill="both", expand=True)
        bf = tk.Frame(top, bd=3, relief="flat", bg="cadet blue")
        bf.pack(side="top", fill="x", expand=True)
        #---------------------------------------------------------------------
        # title
        #---------------------------------------------------------------------
        tf_l = tk.Label(tf, bitmap="question")
        tf_l.pack(side="left", fill="both", expand=True)
        tf_m = tk.Label(tf, justify="left")
        tf_m.pack(side="right", fill="both", expand=True)
        tf_m["text"] = "select constant with <Double-Button-1>"
        #---------------------------------------------------------------------
        # listbox/scrollbar
        #---------------------------------------------------------------------
        yscr= tk.Scrollbar(mf, orient="vertical")
        xscr= tk.Scrollbar(mf, orient="horizontal")
        yscr.pack(side="right",  expand=True, fill="y")
        xscr.pack(side="bottom", expand=True, fill="x")
        lbox = tk.Listbox(mf, relief="raised", height=15, width=60)
        lbox.pack(side="left", expand=True, fill="both")
        yscr.set(0, 0)
        xscr.set(0, 0)
        yscr["command"] = lbox.yview
        xscr["command"] = lbox.xview
        lbox["yscrollcommand"] = yscr.set
        lbox["xscrollcommand"] = xscr.set
        lbox["font"] = "Courier"
        self.__Component["constant_lbox"] = lbox
        #---------------------------------------------------------------------
        # accept and cancel buttons
        #---------------------------------------------------------------------
        bf_cancel = tk.Frame(bf, bd=2, relief="sunken")
        bf_cancel.pack(side="left", expand=True, padx=3, pady=2)
        bf_cancel_button = tk.Button(bf_cancel, text="cancel")
        bf_cancel_button.pack(anchor="c", expand=True, padx=3, pady=2)

        bf_accept = tk.Frame(bf, bd=2, relief="sunken")
        bf_accept.pack(side="left", expand=True, padx=3, pady=2)
        bf_accept_button = tk.Button(bf_accept, text="accept")
        bf_accept_button.pack(anchor="c", expand=True, padx=3, pady=2)

        bf_cancel_button["command"] =  self.__constant_cancel
        bf_accept_button["command"] =  self.__constant_accept
        #---------------------------------------------------------------------
        # bindings
        #---------------------------------------------------------------------
        def cmd(event, self=self) :
            self.__constant_accept()
        lbox.bind("<Double-Button-1>", cmd)
        self.__constant_results = None
        for constant in Calc.constants :
            lbox.insert("end", constant)
        for constant in self.__saved_constants :
            lbox.insert("end", constant)
        lbox.activate(0)
        lbox.selection_set(0)
        top.grab_set()
        top.mainloop()
        top.grab_release()
        top.destroy()
        del self.__Component["constant_top"]
        del self.__Component["constant_lbox"]
        return self.__constant_results
コード例 #7
0
import tkinter as tk

root = tk.Tk()

sb = tk.Scrollbar(root)
sb.pack(side="right", fill="y")

lb = tk.Listbox(root, yscrollcommand=sb.set)

for i in range(1000):
    lb.insert("end", str(i))

lb.pack(side="left", fill="both")

sb.config(command=lb.yview)

root.mainloop()
コード例 #8
0
def StartAFN(E, Q, F, Q0, QF):
    C = entry.get()
    AFN.afnd_start(E, Q, F, Q0, QF, C)
    AFNresultsGUI.GUIstart(C)


label.pack()
entry.pack()
Elabel.pack()
Qlabel.pack()

indice = 0
scrollbar = tk.Scrollbar(window)
scrollbar.pack(side="right", fill="y")
transicoes = format_transition(F)
mylist = tk.Listbox(window, yscrollcommand=scrollbar.set)
for elem in transicoes:
    mylist.insert(indice, elem)
    indice = indice + 1

mylist.pack(side="bottom", fill="both")
scrollbar.config(command=mylist.yview)

#Flabel = tk.Label(text=str(format_transition(F)))
Q0label = tk.Label(text="q0={" + str(Q0) + "}")
QFlabel = tk.Label(text="F={" + str(QF) + "}")
#Flabel.pack()
Q0label.pack()
QFlabel.pack()

submit = tk.Button(window,
コード例 #9
0
def main():
    global listbox
    global image_label
    global summary_label
    global f7, f5, f3
    global btn3
    #btn_font = font.Font(family='Helvetica', size=36, weight='bold')

    # set size the console
    #os.system('mode con: cols=100 lines=20')

    # download all spy file when the window loads at program start
    print('Downloading spy files ...')
    dl = download_spy()
    print('Spy files downloaded complete!')

    # root as the main frame
    root = tk.Tk()

    # frame properties
    #root.resizable(0, 0)
    root.iconbitmap(default='img/icon.ico')
    root.title("COBRA Remote Programming Utility (RPU)")

    f1 = Frame(root)
    f2 = Frame(root)
    f3 = Frame(root)
    f4 = Frame(root)
    f5 = Frame(root)
    f6 = Frame(root)
    f7 = Frame(root)

    for frame in (f1, f2, f3, f4, f5, f6, f7):
        frame.grid(row=0, column=0, sticky='news')

    # f1
    txt0 = 'A simple, free software program for updating COBRA device firmware.'
    lbl0 = tk.Label(f1,
                    text=txt0,
                    justify='left',
                    height=3,
                    font='40',
                    foreground='#53544e').grid(row=0, column=0, columnspan=2)

    btn1 = tk.Button(f1,
                     text='Single Device Update',
                     height=5,
                     width=20,
                     font='20',
                     background='#d4f442',
                     command=lambda: raise_frame(f2, 'goto-f2')).grid(row=1,
                                                                      column=0)

    txt1 = 'A simple, step by step wizard for updating any device including' \
           'the 18R, 18R2, 18M, and Audio Box. All steps include pictures and' \
           'a video for walking you through the simple update procedure.'
    lbl1 = tk.Label(f1,
                    text=txt1,
                    justify='left',
                    height=6,
                    width=50,
                    wraplength=300).grid(row=1, column=1)

    btn2 = tk.Button(f1,
                     text='Update Devices in Batch',
                     height=5,
                     width=20,
                     font='20',
                     background='#33ffbd',
                     command=lambda: raise_frame(f2, 'goto-f2')).grid(row=2,
                                                                      column=0)

    txt2 = 'Updating larger quantities of devices? Use the batch updater to ' \
           'save time and sit back as the program does all the work for you!'
    lbl2 = tk.Label(f1,
                    text=txt2,
                    justify='left',
                    height=6,
                    width=50,
                    wraplength=300).grid(row=2, column=1)

    # f2
    txt3 = 'Update a single device'
    lbl3 = tk.Label(f2,
                    text=txt3,
                    justify='left',
                    height=2,
                    font='40',
                    foreground='#53544e').grid(row=0, column=0, columnspan=4)
    txt4 = '    1. Choose Device to Update'
    lbl4 = tk.Label(f2, text=txt4, justify='left', height=2,
                    font='30').grid(row=1, column=0, columnspan=4)
    ll = tk.Label(f2, text='                 ').grid(
        row=2, column=0)  # just for a gap to the left for following buttons
    btn21 = tk.Button(f2,
                      text='18M',
                      width=10,
                      background='#57c93e',
                      command=lambda: raise_frame(f3, 'goto-f3-18m')).grid(
                          row=2, column=1)
    #btn31 = tk.Button(f2, text='18MB', width = 10, background = '#57c93e',
    #                  command=lambda: raise_frame(f3, 'goto-f3-18mb')).grid(row=3, column=1)
    btn41 = tk.Button(f2,
                      text='18MPA',
                      width=10,
                      background='#57c93e',
                      command=lambda: raise_frame(f3, 'goto-f3-18mpa')).grid(
                          row=3, column=1)
    #btn51 = tk.Button(f2, text='18MBPA', width = 10, background = '#57c93e',
    #                  command=lambda: raise_frame(f3, 'goto-f3-18mbpa')).grid(row=5, column=1)
    btn22 = tk.Button(f2,
                      text='18R',
                      width=10,
                      background='#3e6fc9',
                      command=lambda: raise_frame(f3, 'goto-f3-18r')).grid(
                          row=2, column=2)
    #btn32 = tk.Button(f2, text='18RB', width = 10, background = '#3e6fc9',
    #                  command=lambda: raise_frame(f3, 'goto-f3-18rb')).grid(row=3, column=2)
    btn42 = tk.Button(f2,
                      text='18R2',
                      width=10,
                      background='#3e6fc9',
                      command=lambda: raise_frame(f3, 'goto-f3-18r2')).grid(
                          row=3, column=2)
    btn23 = tk.Button(f2,
                      text='AB',
                      width=10,
                      background='#dd5e3b',
                      command=lambda: raise_frame(f3, 'goto-f3-ab')).grid(
                          row=2, column=3)
    #btn33 = tk.Button(f2, text='ABB', width = 10, background = '#dd5e3b',
    #                  command=lambda: raise_frame(f3, 'goto-f3-abb')).grid(row=3, column=3)
    btn24 = tk.Button(f2,
                      text='90M',
                      width=10,
                      background='#dd3bc4',
                      command=lambda: raise_frame(f3, 'goto-f3-90m')).grid(
                          row=2, column=4)

    l7l = tk.Label(f2, text='                 ').grid(row=4, column=1)
    l72 = tk.Label(f2, text='                 ').grid(row=5, column=1)
    l73 = tk.Label(f2, text='                 ').grid(row=6, column=1)
    btn_bk = tk.Button(f2,
                       text='Back',
                       width=10,
                       command=lambda: raise_frame(f1, 'goto-f1')).grid(
                           row=8, column=1)
    btn_mm = tk.Button(f2,
                       text='Main Menu',
                       width=10,
                       command=lambda: raise_frame(f1, 'goto-f1')).grid(
                           row=8, column=6)
    # f3
    txt5 = 'Update a single device'
    lbl5 = tk.Label(f3,
                    text=txt5,
                    justify='left',
                    height=2,
                    font='40',
                    foreground='#53544e').grid(row=0, column=0, columnspan=4)
    txt6 = '    2. Place Unit in Program Mode'
    lbl6 = tk.Label(f3, text=txt6, justify='left', height=2,
                    font='30').grid(row=1, column=0, columnspan=4)
    ll = tk.Label(f3, text='                 ').grid(
        row=2, column=0)  # just for a gap to the left for following buttons
    txt7 = 'If your current firmware is 3.0.2 or higher, you need to place the device into program mode.\n' \
           '\n1. Power on device' \
           '\n2. Allow unit to boot up until channel is displayed' \
           '\n3. Hold SYNC until P is displayed' \
           '\n4. Once P is displayed, click NEXT to the right.'
    lbl7 = tk.Label(
        f3,
        text=txt7,
        justify='left',
        height=7,
        width=45,
        wraplength=300,
    ).grid(row=2, column=1, columnspan=4)
    btn3 = tk.Button(f3,
                     text='Next',
                     height=5,
                     width=15,
                     font='20',
                     background='#d4f442',
                     command=lambda: raise_frame(f4, 'goto-f4')).grid(
                         row=2, column=5, sticky='NE')
    ll = tk.Label(f3, text='                 ').grid(row=7, column=1)
    btn_bk = tk.Button(f3,
                       text='Back',
                       width=10,
                       command=lambda: raise_frame(f2, 'goto-f2')).grid(
                           row=8, column=1)
    btn_mm = tk.Button(f3,
                       text='Main Menu',
                       width=10,
                       command=lambda: raise_frame(f1, 'goto-f1')).grid(
                           row=8, column=5)

    # f4
    ll = tk.Label(f4, text='             ').grid(row=2, column=0)
    txt33 = 'Update a single device'
    lbl33 = tk.Label(f4,
                     text=txt33,
                     justify='left',
                     height=2,
                     font='40',
                     foreground='#53544e').grid(row=0, column=1, sticky='nw')
    txt34 = 'Scanning Selected Device'
    lbl11 = tk.Label(f4, text=txt34, justify='left', height=2,
                     font='30').grid(row=1, column=1, sticky='nw')
    pb2 = ttk.Progressbar(f4,
                          orient="horizontal",
                          length=200,
                          mode="indeterminate")
    pb2.grid(row=2, column=1, sticky='nw')
    pb2.start()
    ll4 = tk.Label(f4,
                   text='The scan process will take some time, please wait.')
    ll4.grid(row=3, column=1)

    # f5
    txt8 = 'Update a single device'
    lbl8 = tk.Label(f5,
                    text=txt8,
                    justify='left',
                    height=2,
                    font='40',
                    foreground='#53544e').grid(row=0, column=0, columnspan=4)
    txt9 = '    3. Select Firmware Version'
    lbl9 = tk.Label(f5, text=txt9, justify='left', height=2,
                    font='30').grid(row=1, column=0, columnspan=4)
    ll = tk.Label(f5, text='                 ').grid(
        row=2, column=0)  # just for a gap to the left for following buttons

    listbox = tk.Listbox(f5, height=5, width=50)
    listbox.grid(row=2, column=1)
    for item in ["one", "two", "three", "four"]:
        listbox.insert(tk.END, item)
    listbox.bind(
        "<<ListboxSelect>>",
        lambda event, arg=listbox: firmware_version_selection(event, arg))

    ll = tk.Label(f5, text='  ').grid(
        row=2, column=5)  # just for a gap to the left for following buttons
    btn4 = tk.Button(f5,
                     text='Next',
                     height=5,
                     width=15,
                     font='20',
                     background='#d4f442',
                     command=lambda: raise_frame(f6, 'goto-f6')).grid(
                         row=2, column=6, sticky='NE')
    #command=lambda: raise_frame(f6, 'goto-f5')).grid(row=2, column=6, sticky='NE')

    ll = tk.Label(f5, text='                 ').grid(row=7, column=1)
    btn_bk = tk.Button(f5,
                       text='Back',
                       width=10,
                       command=lambda: raise_frame(f3, 'goto-f3')).grid(
                           row=8, column=1)
    btn_mm = tk.Button(f5,
                       text='Main Menu',
                       width=10,
                       command=lambda: raise_frame(f1, 'goto-f1')).grid(
                           row=8, column=6)

    # f6
    ll = tk.Label(f6, text='             ').grid(row=2, column=0)
    txt10 = 'Update a single device'
    lbl10 = tk.Label(f6,
                     text=txt10,
                     justify='left',
                     height=2,
                     font='40',
                     foreground='#53544e').grid(row=0, column=1, sticky='nw')
    txt11 = 'Firmware Upgrade in Progress'
    lbl11 = tk.Label(f6, text=txt11, justify='left', height=2,
                     font='30').grid(row=1, column=1, sticky='nw')
    pb = ttk.Progressbar(f6,
                         orient="horizontal",
                         length=200,
                         mode="indeterminate")
    pb.grid(row=2, column=1, sticky='nw')
    pb.start()
    ll2 = tk.Label(
        f6, text='The upgrade process will take some time, please wait.')
    ll2.grid(row=3, column=1)

    # f7
    txt12 = 'Update a single device'
    lbl12 = tk.Label(f7,
                     text=txt12,
                     justify='left',
                     height=2,
                     font='40',
                     foreground='#53544e').grid(row=0, column=0, columnspan=4)
    txt13 = '        Firmware Upgrade Complete'
    lbl13 = tk.Label(f7, text=txt13, justify='left', height=2,
                     font='30').grid(row=1, column=0, columnspan=4)
    ll = tk.Label(f7, text='                 ').grid(
        row=2, column=0)  # just for a gap to the left for following buttons
    txt14 = 'To confirm your device is on the correct firmware, please power your unit off, ' \
            'then power it on. You will see 5.0.2 selected as the new firmware.' \
            '\nYou are good to go!'
    lbl14 = tk.Label(
        f7,
        text=txt14,
        justify='left',
        height=4,
        wraplength=300,
    ).grid(row=2, column=1, columnspan=4)
    btn6 = tk.Button(f7,
                     text='Select Another Device',
                     height=5,
                     width=15,
                     font='20',
                     background='#d4f442',
                     wraplength=100,
                     command=lambda: raise_frame(f2, 'goto-f2')).grid(
                         row=2, column=6, sticky='NE')

    ll = tk.Label(f7, text='                 ').grid(row=7, column=1)
    btn_bk = tk.Button(f7,
                       text='Back',
                       width=10,
                       command=lambda: raise_frame(f5, 'goto-f5')).grid(
                           row=8, column=1)
    btn_mm = tk.Button(f7,
                       text='Main Menu',
                       width=10,
                       command=lambda: raise_frame(f1, 'goto-f1')).grid(
                           row=8, column=6)

    raise_frame(f1, 'goto-start')
    root.mainloop()
コード例 #10
0
    def __init__(self, parent, controller):
        tk.Frame.__init__(self, parent)
        self.controller = controller
        """ Widget Declearations """

        self.Title = tk.Label(self,
                              text="Send aviablibilty Check",
                              font=controller.title_font)
        self.TeamList = tk.Listbox(self)
        self.GetTeamButton = tk.Button(self,
                                       text="Get Data",
                                       command=self.GetData)
        self.BackButton = tk.Button(
            self,
            text="Back",
            command=lambda: SystemToolKit.BackButtonRun(controller))
        self.SendEmailButton = tk.Button(
            self,
            text="Send All Emails",
            command=lambda: self.SendEmailToAll(controller))
        self.lblPlayers = tk.Label(self, text="Players:")
        self.lblMatches = tk.Label(self, text="Matches:")
        self.MatchList = tk.Listbox(self)
        self.txtTeamNumber = ttk.Entry(self)
        """ Widget Stylings """

        self.Title.config(background="#8ABFD9", fg="#404040", pady="5")
        self.GetTeamButton.config(compound="left",
                                  background="#307292",
                                  relief="flat",
                                  font=("Arial", 10, 'bold'),
                                  padx=5)
        self.BackButton.config(compound="left",
                               background="#307292",
                               relief="flat",
                               font=("Arial", 10, 'bold'),
                               padx=5)
        self.SendEmailButton.config(compound="left",
                                    background="#307292",
                                    relief="flat",
                                    font=("Arial", 10, 'bold'),
                                    padx=5)
        self.lblPlayers.config(justify="right",
                               fg="black",
                               background="#8ABFD9",
                               font=("Arial", 10, 'bold'))
        self.lblMatches.config(justify="right",
                               fg="black",
                               background="#8ABFD9",
                               font=("Arial", 10, 'bold'))
        self.MatchList.config(width="40")
        """ Widget Positions """

        self.Title.grid(row=0, column=0)
        self.GetTeamButton.grid(row=1, column=1)
        self.txtTeamNumber.grid(row=1, column=0)
        self.lblPlayers.grid(row=2, column=0)
        self.TeamList.grid(row=3, column=0)
        self.lblMatches.grid(row=2, column=1)
        self.MatchList.grid(row=3, column=1)
        self.SendEmailButton.grid(row=3, column=3)
        self.BackButton.grid(row=1, column=3)

        self.team = SystemToolKit.readFile(Config.TeamFile)
        self.allPlayers = SystemToolKit.readFile(Config.PlayerFile)
        self.allUsers = SystemToolKit.readFile(Config.UserFile)
        self.TeamPlayers = []
        self.orderedList = []
コード例 #11
0
def test1(master=None):
    lst =['China', 'USA', "UK", "Canada"]
    lstbox_var = tk.StringVar()
    lstbox1 = tk.Listbox(master,
                         listvariable=lstbox_var,
                         selectmode=tk.MULTIPLE,  # SINGLE, MULTIPLE
                         exportselection=True,
                         bg='grey',
                         fg='blue',
                         bd=20,
                         relief='ridge',
                         font=('Arial', 15, 'bold'),
                         selectbackground='red',
                         selectforeground='white',
                         selectborderwidth=2,
                         # setgrid=True
                         )
    lstbox1.pack()

    # method 1 - 设置/添加 选择项
    lst.append('Singapore')
    lstbox_var.set(lst)
    # lstbox_var.set("Python Ruby Perl Lua")


    # method 2 - 设置/添加 选择项
    # for item in lst:
    #     lstbox1.insert(tk.END, item)

    # method 1 - 删除某些选择项
    # 根据索引用del,根据值用remove
    # del lst[1:3]
    lst.remove('USA')
    lstbox_var.set(lst)

    # method 2 - 删除某些选择项
    # lstbox1.delete(1, 2)
    # print(lstbox_var.get())

    def call_back():

        print(lstbox1.size())

        # method 1 - 获取被选择的项
        # items_chosen = []
        # for index in range(len(lst)):
        #     if lstbox1.select_includes(index):
        #         items_chosen.append(lst[index])
        # if len(items_chosen):
        #     result['text'] = str(items_chosen)
        # else:
        #     result['text'] = ""

        # method 2 - 获取被选择的项
        # try:
        #     print(type(lstbox1.selection_get()))
        #     result['text'] = str(lstbox1.selection_get())
        # except:
        #     # 因为当没有任何选项被选择时候,lstbox1.selection_get会报错
        #     result['text'] = ''

        # method 3 - 获取被选择的项
        choices = [lst[x] for x in lstbox1.curselection()]
        # print(lstbox1.curselection(), choices)
        if len(choices):
            result['text'] = str(choices)
        else:
            result['text'] = ''

    tk.Button(master, text='show', command=call_back).pack()
    result = tk.Label(master, width=100, height=4, bg='black', fg='red')
    result.pack()
コード例 #12
0
ファイル: test_windows_004.py プロジェクト: cololk/python-lib
#建立標籤物件
l =tk.Label(window, bg='yellow', width=4, textvariable=var1) #var1 這個字串變數作為標籤顯示的值
l.pack()

def print_selection():
	value=lb.get(lb.curselection())  #curselection意指光標, 此段指從listbox物件的光標讀取
	var1.set(value) #讀取到的光標指到的數值設定為var1

#建立按鈕物件
b1 = tk.Button(window, text='print selection', width=15, 
	height=2, command=print_selection)
b1.pack() #進行擺放

var2 = tk.StringVar()
var2.set((11,22,33,44))
#建立Listbox物件
lb = tk.Listbox(window,listvariable=var2)
list_items=[1,2,3,4]
for item in list_items:
	lb.insert('end',item)
lb.insert(1,'first')
lb.insert(2,'second')
lb.delete(2)
lb.pack()



window.mainloop()


コード例 #13
0
    feedback_btn.grid(row=3, column=2, rowspan=4, columnspan=4)

    split_label = tkinter.Label(root)
    split_label.grid(row=7, column=0, columnspan=4)
    split_label.configure(
        text=
        '--------------------------------------------------------------------------------------------------------------'
    )

    fur_label = tkinter.Label(root, text='家具类型')
    fur_label.grid(row=8, column=0, rowspan=5)
    #scrolly=tkinter.Scrollbar(root)
    #scrolly.grid(row=7, column=1)

    myList = ['床', '衣柜', '沙发', '餐桌', '书桌']
    lb = tkinter.Listbox(root, selectmode=tkinter.SINGLE, height=6)
    #lb.configure(yscrollcommand=scrolly.set)
    for item in myList:
        lb.insert(tkinter.END, item)
    lb.select_set(0)
    lb.grid(row=8, column=1, rowspan=5)
    #scrolly.configure(command=lb.yview)
    '''
    tkinter.Label(root, text='床尺寸x-y:').grid(row=8,column=2)
    bed_x = tkinter.Entry(root)
    bed_x.grid(row=8,column=3)
    bed_x.insert(0, '1800')
    bed_y = tkinter.Entry(root)
    bed_y.grid(row=8,column=4)
    bed_y.insert(0, '2000')
コード例 #14
0
ファイル: displayer.py プロジェクト: Starry326/AZUL_game
    def InitDisplayer(self, runner):
        self.root = tkinter.Tk()
        self.center_token = True
        self.root.title(
            "AZUL assignment ------ COMP90054 AI Planning for Autononmy")

        self.root.tk.call(
            'wm', 'iconphoto', self.root._w,
            tkinter.PhotoImage(file='resources/azul_bpj_icon.png'))
        self.root.geometry("1300x700")
        # self.root.resizable(width=False, height=False)

        self.tile_images = []
        self.tile_images.append(
            tkinter.PhotoImage(file="resources/blue_tile_mini.png"))
        self.tile_images.append(
            tkinter.PhotoImage(file="resources/yellow_tile_mini.png"))
        self.tile_images.append(
            tkinter.PhotoImage(file="resources/red_tile_mini.png"))
        self.tile_images.append(
            tkinter.PhotoImage(file="resources/black_tile_mini.png"))
        self.tile_images.append(
            tkinter.PhotoImage(file="resources/white_tile_mini.png"))
        self.tile_images.append(
            tkinter.PhotoImage(file="resources/start_tile_mini.png"))
        self.tile_images.append(
            tkinter.PhotoImage(file="resources/penalty_tile_mini.png"))

        self.player_borad_img = tkinter.PhotoImage(
            file="resources/player_board_mini.png")
        self.m_img = tkinter.PhotoImage(
            file="resources/multiplication_mini.png")

        #factory
        self.fb_frame = tkinter.Frame(self.root)
        self.fb_frame.grid(row=0, column=0, sticky=tkinter.W + tkinter.E)

        self.board_factories = []
        self.ft_num = []
        for i in range(5):
            self.ft_num.append([tkinter.StringVar() for _ in range(5)])
        self.ft_num.append([tkinter.StringVar() for _ in range(6)])
        for row in self.ft_num:
            for var in row:
                var.set("0")

        for i in range(5):
            factory = display_utils.BoardFactory(i)
            factory.factory_displayer = tkinter.Frame(
                self.fb_frame,
                highlightbackground="black",
                highlightcolor="black",
                highlightthickness=3,
                borderwidth=2)
            factory.factory_displayer.grid(row=i, column=0)
            #factory.factory_displayer.grid_propagate(False)
            self._GenerateFactory(factory, i, 5)
            self.board_factories.append(factory)
        self.cf_board = display_utils.BoardFactory(6)
        self.cf_board.factory_displayer = tkinter.Frame(
            self.fb_frame,
            highlightbackground="black",
            highlightcolor="black",
            highlightthickness=3)
        self.cf_board.factory_displayer.grid(row=5, column=0)
        self._GenerateFactory(self.cf_board, 5, 6)

        #player board
        self.pb_frame = tkinter.Frame(self.root)
        self.pb_frame.grid(row=0, column=1, sticky=tkinter.W + tkinter.E)

        self.player_board = []
        # assert(len(player_list) == 2)
        for i in range(2):
            name = tkinter.StringVar()
            name.set("Player (" + str(i) + "): " +
                     str(runner.players_namelist[i]) + "")
            pb1 = display_utils.PlayerBoard(
                i, tkinter.Canvas(self.pb_frame, width=405, height=265),
                tkinter.Entry(self.pb_frame, textvariable=name, width=40))
            pb1.naming.grid(row=i * 2, column=0)
            pb1.display_board.grid(row=i * 2 + 1, column=0)
            pb1.display_board.create_image(0,
                                           0,
                                           anchor=tkinter.NW,
                                           image=self.player_borad_img)

            self.player_board.append(pb1)

        #scoreboard
        self.sb_frame = tkinter.Frame(self.root)
        self.sb_frame.grid(row=0, column=2, sticky=tkinter.N + tkinter.E)

        self.scrollbar = tkinter.Scrollbar(self.sb_frame,
                                           orient=tkinter.VERTICAL)

        self.move_box = tkinter.Listbox(self.sb_frame,
                                        name="moves:",
                                        height=37,
                                        width=88,
                                        selectmode="single",
                                        borderwidth=4,
                                        yscrollcommand=self.scrollbar.set)
        self.scrollbar.config(command=self.move_box.yview,
                              troughcolor="white",
                              bg="white")
        self.scrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
        self.move_box.pack(side=tkinter.LEFT, fill=tkinter.BOTH, expand=1)
        # self.move_box.configure(exportselection=False)
        # self.move_box.configure(state=tkinter.DISABLED)

        # self.move_box.grid(row=0, column=3, rowspan=3, sticky=tkinter.N+tkinter.E)

        #self.fb_frame.grid_propagate(0)
        #self.root.grid_propagate(0)

        self.game_state_history = []
        self.round_num = 0
コード例 #15
0
        html = requests.get(
            f"http://music.163.com/song/media/outer/url?id={id}")

        path = r"./Music"
        os.makedirs(path, exist_ok=True)

        _path = os.path.join(path, f"{name}.mp3")

        with open(_path, 'wb') as file:
            file.write(html.content)

        print(f"歌曲名为:{name} 且id为:{id} 已下载完成......")


win = tkinter.Tk()

win.title("网易云音乐歌曲下载")

label_info = tkinter.Label(win)
display_info = tkinter.Listbox(win, width=80)

translate_btn = tkinter.Button(win,
                               text='点击此处才能弹出输入id和歌曲名称',
                               command=download_source)

label_info.pack()
translate_btn.pack()
display_info.pack()

tkinter.mainloop()
コード例 #16
0
ファイル: ui.py プロジェクト: dominicshields/Python
    def create_widgets(self):
        # Create some room around all the internal frames
        self.window['padx'] = 5
        self.window['pady'] = 5

        # - - - - - - - - - - - - - - - - - - - - -
        # The Commands frame
        # cmd_frame = ttk.LabelFrame(self.window, text="Commands", padx=5, pady=5, relief=tk.RIDGE)
        cmd_frame = ttk.LabelFrame(self.window,
                                   text="Commands",
                                   relief=tk.RIDGE)
        cmd_frame.grid(row=1, column=1, sticky=tk.E + tk.W + tk.N + tk.S)

        button_label = ttk.Label(cmd_frame, text="tk.Button")
        button_label.grid(row=1, column=1, sticky=tk.W, pady=3)

        button_label = ttk.Label(cmd_frame, text="ttk.Button")
        button_label.grid(row=2, column=1, sticky=tk.W, pady=3)

        menu_label = ttk.Label(cmd_frame, text="Menu (see examples above)")
        menu_label.grid(row=3, column=1, columnspan=2, sticky=tk.W, pady=3)

        my_button = tk.Button(cmd_frame, text="do something")
        my_button.grid(row=1, column=2)

        my_button = ttk.Button(cmd_frame, text="do something")
        my_button.grid(row=2, column=2)

        # - - - - - - - - - - - - - - - - - - - - -
        # The Data entry frame
        entry_frame = ttk.LabelFrame(self.window,
                                     text="Data Entry",
                                     relief=tk.RIDGE)
        entry_frame.grid(row=2, column=1, sticky=tk.E + tk.W + tk.N + tk.S)

        entry_label = ttk.Label(entry_frame, text="ttk.Entry")
        entry_label.grid(row=1, column=1, sticky=tk.W + tk.N)

        text_label = ttk.Label(entry_frame, text="tk.Text")
        text_label.grid(row=2, column=1, sticky=tk.W + tk.N)

        scale_label = ttk.Label(entry_frame, text="tk.Scale")
        scale_label.grid(row=4, column=1, sticky=tk.W)

        scale_label2 = ttk.Label(entry_frame, text="ttk.Scale")
        scale_label2.grid(row=5, column=1, sticky=tk.W)

        my_entry = ttk.Entry(entry_frame, width=40)
        my_entry.grid(row=1, column=2, sticky=tk.W, pady=3)
        my_entry.insert(tk.END, "Test")

        my_text = tk.Text(entry_frame, height=5, width=30)
        my_text.grid(row=2, column=2)
        my_text.insert(tk.END, "An example of multi-line\ninput")

        my_spinbox = tk.Spinbox(entry_frame,
                                from_=0,
                                to=10,
                                width=5,
                                justify=tk.RIGHT)
        my_spinbox.grid(row=3, column=2, sticky=tk.W, pady=3)

        my_scale = tk.Scale(entry_frame,
                            from_=0,
                            to=100,
                            orient=tk.HORIZONTAL,
                            width=8,
                            length=200)
        my_scale.grid(row=4, column=2, sticky=tk.W)

        my_scale = ttk.Scale(entry_frame,
                             from_=0,
                             to=100,
                             orient=tk.HORIZONTAL,
                             length=200)

        my_scale.grid(row=5, column=2, sticky=tk.W)

        # - - - - - - - - - - - - - - - - - - - - -
        # The Choices frame
        switch_frame = ttk.LabelFrame(self.window,
                                      text="Choices",
                                      relief=tk.RIDGE,
                                      padding=6)
        switch_frame.grid(row=2,
                          column=2,
                          padx=6,
                          sticky=tk.E + tk.W + tk.N + tk.S)

        checkbox_label = ttk.Label(switch_frame, text="ttk.Checkbutton")
        checkbox_label.grid(row=1, rowspan=3, column=1, sticky=tk.W + tk.N)

        entry_label = ttk.Label(switch_frame, text="ttk.Radiobutton")
        entry_label.grid(row=4, rowspan=3, column=1, sticky=tk.W + tk.N)

        checkbutton1 = ttk.Checkbutton(switch_frame, text="On-off switch 1")
        checkbutton1.grid(row=1, column=2)
        checkbutton2 = ttk.Checkbutton(switch_frame, text="On-off switch 2")
        checkbutton2.grid(row=2, column=2)
        checkbutton3 = ttk.Checkbutton(switch_frame, text="On-off switch 3")
        checkbutton3.grid(row=3, column=2)

        self.radio_variable = tk.StringVar()
        self.radio_variable.set("0")

        radiobutton1 = ttk.Radiobutton(switch_frame,
                                       text="Choice One of three",
                                       variable=self.radio_variable,
                                       value="0")
        radiobutton2 = ttk.Radiobutton(switch_frame,
                                       text="Choice Two of three",
                                       variable=self.radio_variable,
                                       value="1")
        radiobutton3 = ttk.Radiobutton(switch_frame,
                                       text="Choice Three of three",
                                       variable=self.radio_variable,
                                       value="2")
        radiobutton1.grid(row=4, column=2, sticky=tk.W)
        radiobutton2.grid(row=5, column=2, sticky=tk.W)
        radiobutton3.grid(row=6, column=2, sticky=tk.W)

        # - - - - - - - - - - - - - - - - - - - - -
        # The Choosing from lists frame
        fromlist_frame = ttk.LabelFrame(self.window,
                                        text="Choosing from a list",
                                        relief=tk.RIDGE)
        fromlist_frame.grid(row=1,
                            column=2,
                            sticky=tk.E + tk.W + tk.N + tk.S,
                            padx=6)

        listbox_label = tk.Label(fromlist_frame, text="tk.Listbox")
        listbox_label.grid(row=1, column=1, sticky=tk.W + tk.N)

        combobox_label = tk.Label(fromlist_frame, text="ttk.Combobox")
        combobox_label.grid(row=2, column=1, sticky=tk.W + tk.N)

        my_listbox = tk.Listbox(fromlist_frame, height=4)
        for item in ["one", "two", "three", "four"]:
            my_listbox.insert(tk.END, "Choice " + item)
        my_listbox.grid(row=1, column=2)

        self.combobox_value = tk.StringVar()
        my_combobox = ttk.Combobox(fromlist_frame,
                                   height=4,
                                   textvariable=self.combobox_value)
        my_combobox.grid(row=2, column=2)
        my_combobox['values'] = ("Choice one", "Choice two", "Choice three",
                                 "Choice four")
        my_combobox.current(0)

        # - - - - - - - - - - - - - - - - - - - - -
        # Menus
        menubar = tk.Menu(self.window)

        filemenu = tk.Menu(menubar, tearoff=0)
        filemenu.add_command(label="Open", command=filedialog.askopenfilename)
        filemenu.add_command(label="Save",
                             command=filedialog.asksaveasfilename)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.window.quit)
        menubar.add_cascade(label="File", menu=filemenu)

        self.window.config(menu=menubar)

        # - - - - - - - - - - - - - - - - - - - - -
        # Quit button in the lower right corner
        quit_button = ttk.Button(self.window,
                                 text="Quit",
                                 command=self.window.destroy)
        quit_button.grid(row=1, column=3)
コード例 #17
0
ファイル: checklist.py プロジェクト: fluff905/To-Do-List
               font="Saab 20",
               textvariable=content)
entry1.place(x=450, y=350)

button1 = Button(root,
                 text="Enter",
                 bg="LightBlue2",
                 fg="pink2",
                 font="Saab 25",
                 command=insertitem)
button1.place(x=450, y=400)
button2 = Button(root,
                 text="Delete list",
                 bg="LightBlue2",
                 fg="pink2",
                 font="Saab 25",
                 command=deletelist)
button2.place(x=450, y=430)
button3 = Button(root,
                 text="Delete selected item",
                 bg="LightBlue2",
                 fg="pink2",
                 font="Saab 25",
                 command=deleteitemselected)
button3.place(x=450, y=460)

listbox = tk.Listbox(root)
listbox.place(x=450, y=490)

root.mainloop()
コード例 #18
0
ファイル: Greeting.py プロジェクト: mipsparc/ScaleSpeedCamera
    def __init__(self, root, camera_ids, version, old_ver):
        self.root = root
        iconimg = tkinter.PhotoImage(data=ICON)
        root.iconphoto(True, iconimg)
        self.root.title("ScaleSpeedCamera")
        self.root.resizable(False, False)
        s = ttk.Style()
        if 'winnative' in s.theme_names():
            s.theme_use('winnative')
        else:
            s.theme_use('alt')

        if old_ver:
            messagebox.showinfo(
                '更新をお願いします',
                message=
                '最新のバージョンが出ています。\ngithub.com/mipsparc/ScaleSpeedCamera/releases'
            )

        mainframe = ttk.Frame(self.root, padding="12 12 12 12")
        mainframe.grid(column=0,
                       row=0,
                       sticky=(tkinter.N, tkinter.W, tkinter.E, tkinter.S))

        greeting = tkinter.Label(mainframe,
                                 text=f'バージョン{version}  初期設定を行ってください')
        greeting.grid(column=1, row=1)

        scale_frame = ttk.LabelFrame(mainframe,
                                     text='縮尺(直接入力可)',
                                     padding="12 12 12 12")
        self.custom_gauge = tkinter.StringVar(value='1/150')
        self.gauge_input = ttk.Entry(scale_frame,
                                     textvariable=self.custom_gauge)
        gauges = tkinter.StringVar(value=('(N) 1/150', '(HO) 1/80',
                                          '(N) 1/160', '(HO) 1/87',
                                          '(Z) 1/220'))
        gauges_box = tkinter.Listbox(scale_frame,
                                     listvariable=gauges,
                                     height=5)
        self.gauge_input.grid(column=0, row=0, padx=20, pady=20)
        gauges_box.grid(column=0, row=1, padx=20)
        scale_frame.grid(column=1, row=2, sticky=tkinter.N + tkinter.S)

        self.speed_system = tkinter.StringVar()
        speed_system_frame = ttk.LabelFrame(mainframe,
                                            padding="12 12 12 12",
                                            text='単位系')
        kph_sys = ttk.Radiobutton(speed_system_frame,
                                  text='km/h',
                                  variable=self.speed_system,
                                  value='kph')
        mph_sys = ttk.Radiobutton(speed_system_frame,
                                  text='MPH',
                                  variable=self.speed_system,
                                  value='mph')
        kph_sys.grid(column=0, row=0, sticky=tkinter.N, padx=20)
        mph_sys.grid(column=0, row=1, sticky=tkinter.N, padx=20)
        self.speed_system.set('kph')
        speed_system_frame.grid(column=2, row=2, sticky=tkinter.N + tkinter.S)

        camera_names = []
        for cam in camera_ids:
            camera_names.append(f'カメラ {cam}')
        camera_frame = ttk.LabelFrame(mainframe,
                                      text='カメラ選択',
                                      padding="12 12 12 12")
        self.cameras = tkinter.StringVar(value=tuple(camera_names))
        self.camera_box = tkinter.Listbox(camera_frame,
                                          listvariable=self.cameras,
                                          height=5)
        self.camera_box.grid(column=0, row=0, padx=20)
        camera_frame.grid(column=3, row=2, sticky=tkinter.N + tkinter.S)

        self.save_photo = tkinter.BooleanVar()
        save_checkbox = ttk.Checkbutton(mainframe,
                                        text='通過時写真を保存する',
                                        variable=self.save_photo)
        save_checkbox.grid(column=3, row=3)

        for child in mainframe.winfo_children():
            child.grid_configure(padx=5, pady=5)

        ttk.Button(mainframe, text="はじめる",
                   command=self.final).grid(column=3,
                                            row=4,
                                            sticky=(tkinter.E, tkinter.S))

        gauges_box.bind("<<ListboxSelect>>", self.selectGauge)
        self.root.bind("<Return>", self.final)

        self.root.mainloop()
コード例 #19
0
    def create_listbox(self):
        self._sbframe = tk.Frame(self)

        list_label = tk.Frame(self._sbframe)
        list_label.pack(side=tk.TOP, anchor=tk.N, fill=tk.X)
        tk.Label(list_label, text="Name:").pack(side=tk.LEFT, anchor=tk.W)
        self.name_filter = tk.Entry(list_label, width=14)
        self.name_filter.pack(side=tk.LEFT, anchor=tk.W)
        tk.Button(list_label,
                  text="Select",
                  command=lambda: self.select_by_name()).pack(side=tk.LEFT,
                                                              anchor=tk.W)
        self.sblabel = tk.Label(list_label, text="Showing: 0")
        self.sblabel.pack(side=tk.RIGHT)

        self.scrollbar = tk.Scrollbar(self._sbframe)
        self.listbox = tk.Listbox(self._sbframe,
                                  yscrollcommand=self.scrollbar.set,
                                  selectmode=tk.EXTENDED,
                                  width=30)
        self.scrollbar.config(command=self.listbox.yview)

        self.list_tools = tk.Frame(self._sbframe)
        tk.Button(self.list_tools,
                  text="To Top",
                  command=lambda: self.move_selected_to_top()).pack(
                      side=tk.TOP, anchor=tk.NW, fill=tk.X)
        tk.Button(self.list_tools,
                  text="Select All",
                  command=lambda: self.select_all()).pack(side=tk.TOP,
                                                          anchor=tk.NW,
                                                          fill=tk.X)
        tk.Button(self.list_tools,
                  text="Clear",
                  command=lambda: self.unselect_all()).pack(side=tk.TOP,
                                                            anchor=tk.NW,
                                                            fill=tk.X)
        tk.Button(self.list_tools,
                  text="Invert",
                  command=lambda: self.invert_selection()).pack(side=tk.TOP,
                                                                anchor=tk.NW,
                                                                fill=tk.X)

        self.color_field = tk.Frame(self.list_tools)
        tk.Label(self.color_field, text="Color:").pack(side=tk.LEFT)

        self.color_pick = tk.Button(self.color_field,
                                    text="",
                                    command=lambda: self.change_color(),
                                    bg='#000000')
        self.color_pick.pack(side=tk.RIGHT,
                             anchor=tk.NW,
                             fill=tk.X,
                             expand=True)

        self.color_field.pack(side=tk.TOP, anchor=tk.NW, fill=tk.X)

        self.list_tools.pack(side=tk.RIGHT, anchor=tk.NW)
        self.scrollbar.pack(side=tk.RIGHT, anchor=tk.E, fill=tk.Y)
        self.listbox.pack(side=tk.RIGHT, anchor=tk.E, fill=tk.Y)
        self.listbox.bind('<<ListboxSelect>>',
                          lambda x: self.set_head(self.listbox.curselection()))
        self._sbframe.pack(side=tk.RIGHT, anchor=tk.E, fill=tk.Y)
コード例 #20
0
    def __init__(self, root):
        #setting title
        self.root = root
        self.root.title("Tesla Dashcam Enhancer")
        #setting window size
        width=250
        height=720
        self.filenameOpen = ""
        self.filenameClose = ""
        self.interval = 300
        screenwidth = self.root.winfo_screenwidth()
        screenheight = self.root.winfo_screenheight()
        alignstr = '%dx%d+%d+%d' % (width, height, (screenwidth - width) / 2, (screenheight - height) / 2)
        self.root.geometry(alignstr)
        self.root.resizable(width=False, height=False)


        #Get all the available filters
        self.filter_list = os.listdir("cube_files")

        #Create GUI Elements
        self.GButton_select_vid=tk.Button(self.root)
        self.GButton_select_vid["bg"] = "#f0f0f0"
        ft = tkFont.Font(family='Times',size=10)
        self.GButton_select_vid["font"] = ft
        self.GButton_select_vid["fg"] = "#000000"
        self.GButton_select_vid["justify"] = "center"
        self.GButton_select_vid["text"] = "Select Video"
        self.GButton_select_vid.place(x=75,y=30,width=125,height=45)
        self.GButton_select_vid["command"] = self.GButton_select_vid_command

        self.GButton_select_save=tk.Button(self.root)
        self.GButton_select_save["bg"] = "#f0f0f0"
        ft = tkFont.Font(family='Times',size=10)
        self.GButton_select_save["font"] = ft
        self.GButton_select_save["fg"] = "#000000"
        self.GButton_select_save["justify"] = "center"
        self.GButton_select_save["text"] = "Select Save Location"
        self.GButton_select_save.place(x=75,y=130,width=125,height=45)
        self.GButton_select_save["command"] = self.GButton_select_save_command

        self.GListBox_select_filter = tk.Listbox(self.root)
        self.GListBox_select_filter["borderwidth"] = "1px"
        ft = tkFont.Font(family='Times',size=10)
        self.GListBox_select_filter["font"] = ft
        self.GListBox_select_filter["fg"] = "#333333"
        self.GListBox_select_filter["justify"] = "center"
        height_box = min(5,len(self.filter_list))
        self.GListBox_select_filter.place(x=75,y=235,width=125,height=17*height_box)
        for item in self.filter_list:
            self.GListBox_select_filter.insert("end",item)
        self.GListBox_select_filter["selectmode"] = "browse"

        self.GButton_preview=tk.Button(self.root)
        self.GButton_preview["bg"] = "#f0f0f0"
        ft = tkFont.Font(family='Times',size=10)
        self.GButton_preview["font"] = ft
        self.GButton_preview["fg"] = "#000000"
        self.GButton_preview["justify"] = "center"
        self.GButton_preview["text"] = "Preview"
        self.GButton_preview.place(x=75,y=450,width=125,height=45)
        self.GButton_preview["command"] = self.GButton_preview_command

        self.Label_time = tk.Label(self.root)
        self.Label_time["text"] = "Set preview duration \ndefault 10s"
        self.Label_time.place(x=75, y=350, width=125, height=45)

        self.GEntry_time = tk.Entry(self.root)
        self.GEntry_time["bg"] = "#FFFFFF"
        self.GEntry_time.insert(0,str(10))
        self.GEntry_time.place(x=75, y=400, width=125, height=45)

        self.GButton_start_enhancement=tk.Button(self.root)
        self.GButton_start_enhancement["bg"] = "#f0f0f0"
        ft = tkFont.Font(family='Times',size=10)
        self.GButton_start_enhancement["font"] = ft
        self.GButton_start_enhancement["fg"] = "#000000"
        self.GButton_start_enhancement["justify"] = "center"
        self.GButton_start_enhancement["text"] = "Enhance"
        self.GButton_start_enhancement.place(x=75,y=530,width=125,height=45)
        self.GButton_start_enhancement["command"] = self.GButton_start_enhancement_command

        self.GProgressbar = ttk.Progressbar(root)
        self.GProgressbar["orient"] = HORIZONTAL
        self.GProgressbar["length"] = 100
        self.GProgressbar["mode"] = 'determinate'
        self.GProgressbar.place(x=75,y=600,width=125,height=45)

        self.GButton_exit=tk.Button(self.root)
        self.GButton_exit["bg"] = "#f0f0f0"
        ft = tkFont.Font(family='Times',size=10)
        self.GButton_exit["font"] = ft
        self.GButton_exit["fg"] = "#000000"
        self.GButton_exit["justify"] = "center"
        self.GButton_exit["text"] = "Exit"
        self.GButton_exit.place(x=75,y=650,width=125,height=45)
        self.GButton_exit["command"] = exit
        self.frame_no = 0
コード例 #21
0
ファイル: checklist.py プロジェクト: falaqm/ArtOfDoingTkinter
btn_add_list = tk.Button(input_frame,
                         text="Add item",
                         borderwidth=2,
                         font=my_font,
                         bg=button_color,
                         command=add_item)

ent_list.grid(row=0, column=0, padx=5, pady=5)
btn_add_list.grid(row=0, column=1, padx=5, pady=5, ipadx=7)

## output frame layout
my_scrollbar = tk.Scrollbar(output_frame)

my_listbox = tk.Listbox(master=output_frame,
                        height=15,
                        width=45,
                        borderwidth=3,
                        font=my_font,
                        yscrollcommand=my_scrollbar.set)

my_listbox.grid(row=0, column=0)
my_scrollbar.grid(row=0, column=1, sticky='ns')

# link scrollbar to listbox
my_scrollbar.config(command=my_listbox.yview)

## button frame layout

btn_list_remove = tk.Button(master=button_frame,
                            text="Remove item",
                            borderwidth=2,
                            font=my_font,
コード例 #22
0
ファイル: datareader.py プロジェクト: JStraq/toolbox
    def __init__(self):
        self.output = None
        self.fnames = []
        self.window = tk.Tk()
        tk.Label(self.window, text='Folder:').grid(row=0,
                                                   column=0,
                                                   sticky='NSEW')
        self.activeFolder = tk.Entry(self.window, width=75)
        self.activeFolder.grid(row=0, column=1, columnspan=2, sticky='NSEW')
        tk.Button(self.window, text='Select',
                  command=self.chooseFolder).grid(row=0,
                                                  column=3,
                                                  sticky='NSEW')

        self.window.grid_columnconfigure(0, weight=0)
        self.window.grid_columnconfigure(1, weight=1)
        self.window.grid_columnconfigure(2, weight=1)
        self.window.grid_columnconfigure(3, weight=0)
        self.window.grid_columnconfigure(4, weight=0)
        self.window.grid_columnconfigure(5, weight=0)
        self.window.grid_columnconfigure(6, weight=1)

        self.filelist = tk.Listbox(self.window,
                                   height=10,
                                   selectmode=tk.MULTIPLE,
                                   exportselection=0)
        self.filelist.grid(row=1,
                           column=0,
                           columnspan=4,
                           rowspan=10,
                           sticky='NSEW')
        self.filelist.bind("<<ListboxSelect>>", self.updateHeaders)

        tk.Button(self.window, text='select all',
                  command=self.selectall).grid(row=11,
                                               column=0,
                                               columnspan=2,
                                               sticky='NSEW')
        tk.Button(self.window, text='select none',
                  command=self.selectnone).grid(row=11,
                                                column=2,
                                                columnspan=2,
                                                sticky='NSEW')

        self.mode = tk.IntVar()
        self.mode.set(1)

        tk.Radiobutton(self.window,
                       text="create indexed list",
                       variable=self.mode,
                       value=1).grid(row=12, column=1, sticky='NSEW')
        tk.Radiobutton(self.window,
                       text="combine all files",
                       variable=self.mode,
                       value=2).grid(row=12, column=2, sticky='NSEW')

        genbutton = tk.Button(self.window,
                              text='GENERATE',
                              command=self.generate).grid(row=13,
                                                          column=0,
                                                          columnspan=4,
                                                          sticky='NSEW')

        self.headers = []
        self.headlabels = []
        self.colboxes = []
        self.saveboxes = []
        self.savetraces = []

        self.window.grab_set()

        tk.mainloop()
コード例 #23
0
ファイル: chat-client.py プロジェクト: a-farooq/Python

def on_closing(event=None):
    """This function is to be called when the window is closed."""
    my_msg.set("{quit}")
    send()

top = tkinter.Tk()
top.title("Chatter")

messages_frame = tkinter.Frame(top)
my_msg = tkinter.StringVar()  # For the messages to be sent.
my_msg.set("Type your messages here.")
scrollbar = tkinter.Scrollbar(messages_frame)  # To navigate through past messages.
# Following will contain the messages.
msg_list = tkinter.Listbox(messages_frame, height=15, width=50, yscrollcommand=scrollbar.set)
scrollbar.pack(side=tkinter.RIGHT, fill=tkinter.Y)
msg_list.pack(side=tkinter.LEFT, fill=tkinter.BOTH)
msg_list.pack()
messages_frame.pack()

entry_field = tkinter.Entry(top, textvariable=my_msg)
entry_field.bind("<Return>", send)
entry_field.pack()
send_button = tkinter.Button(top, text="Send", command=send)
send_button.pack()

top.protocol("WM_DELETE_WINDOW", on_closing)

#----Now comes the sockets part----
HOST = input('Enter host: ')
コード例 #24
0
ファイル: main.py プロジェクト: mecubey/Pyplayer
shuffle_on.place(relx=0.1, rely=0.0)

# text to show if repeating audiofile is on or off
repeat_on = tk.Label(root,
                     text="REPEAT OFF",
                     height=1,
                     width=15,
                     bg="black",
                     fg="white")
repeat_on.place(relx=0.75, rely=0.0)

files_list = []
new_file_list = []

# list that is showing all audiofiles in chosen directory
audiofiles = tk.Listbox(root, width=87, height=20, bg="black", fg="white")
audiofiles.place(relx=0.0, rely="0.1")

# bool to control thread-flow
dead = False

# bool to control if shuffle is on or off
default_shuffle = False

# bool to control if repeating audio is on or off
default_repeat = False


def list_audio():
    """
    list_audio description
コード例 #25
0
    def create_widgets(self):
        toplevel_frame = ttk.Frame(self, padding='0.1i')

        (self.toolslist, selected_item) = self.get_tools_list()
        self.tools_frame = ttk.LabelFrame(toplevel_frame,
                                          text="{} Available Tools".format(
                                              len(self.toolslist)),
                                          padding='0.1i')
        self.toolnames = tk.StringVar(value=self.toolslist)
        self.tools_listbox = tk.Listbox(self.tools_frame,
                                        height=22,
                                        listvariable=self.toolnames)
        self.tools_listbox.bind("<<ListboxSelect>>", self.update_tool_help)
        self.tools_listbox.grid(row=0, column=0, sticky=tk.NSEW)
        self.tools_listbox.columnconfigure(0, weight=10)
        self.tools_listbox.rowconfigure(0, weight=1)
        s = ttk.Scrollbar(self.tools_frame,
                          orient=tk.VERTICAL,
                          command=self.tools_listbox.yview)
        s.grid(row=0, column=1, sticky=(tk.N, tk.S))
        self.tools_listbox['yscrollcommand'] = s.set
        self.tools_frame.grid(row=0, column=0, sticky=tk.NSEW)
        self.tools_frame.columnconfigure(0, weight=10)
        self.tools_frame.columnconfigure(1, weight=1)
        self.tools_frame.rowconfigure(0, weight=1)

        overall_frame = ttk.Frame(toplevel_frame, padding='0.1i')

        # json_str = '{"default_value": null, "description": "Directory containing data files.", "flags": ["--wd"], "name": "Working Directory", "optional": true, "parameter_type": "Directory"}'
        # self.wd = FileSelector(json_str, overall_frame)
        # self.wd.grid(row=0, column=0, sticky=tk.NSEW)

        current_tool_frame = ttk.Frame(overall_frame, padding='0.1i')
        self.current_tool_lbl = ttk.Label(
            current_tool_frame,
            text="Current Tool: {}".format(self.tool_name),
            justify=tk.LEFT)  # , font=("Helvetica", 12, "bold")
        self.current_tool_lbl.grid(row=0, column=0, sticky=tk.W)
        self.view_code_button = ttk.Button(current_tool_frame,
                                           text="View Code",
                                           width=8,
                                           command=self.view_code)
        self.view_code_button.grid(row=0, column=1, sticky=tk.E)
        current_tool_frame.grid(row=1, column=0, sticky=tk.NSEW)
        current_tool_frame.columnconfigure(0, weight=1)
        current_tool_frame.columnconfigure(1, weight=1)

        tool_args_frame = ttk.Frame(overall_frame, padding='0.0i')
        self.tool_args_frame = ttk.Frame(overall_frame, padding='0.0i')
        self.tool_args_frame.grid(row=2, column=0, sticky=tk.NSEW)
        self.tool_args_frame.columnconfigure(0, weight=1)

        # args_frame = ttk.Frame(overall_frame, padding='0.1i')
        # self.args_label = ttk.Label(args_frame, text="Tool Arguments:", justify=tk.LEFT)
        # self.args_label.grid(row=0, column=0, sticky=tk.W)
        # args_frame2 = ttk.Frame(args_frame, padding='0.0i')
        # self.args_value = tk.StringVar()
        # self.args_text = ttk.Entry(args_frame2, width=45, justify=tk.LEFT, textvariable=self.args_value)
        # self.args_text.grid(row=0, column=0, sticky=tk.NSEW)
        # self.args_text.columnconfigure(0, weight=1)
        # self.clearButton = ttk.Button(args_frame2, text="Clear", width=4, command=self.clear_args_box)
        # self.clearButton.pack(pady=10, padx=10)
        # self.clearButton.grid(row=0, column=1, sticky=tk.E)
        # self.clearButton.columnconfigure(0, weight=1)
        # args_frame2.grid(row=1, column=0, sticky=tk.NSEW)
        # args_frame2.columnconfigure(0, weight=10)
        # args_frame2.columnconfigure(1, weight=1)
        # args_frame.grid(row=2, column=0, sticky=tk.NSEW)
        # args_frame.columnconfigure(0, weight=1)

        # # Add the bindings
        # if _platform == "darwin":
        #     self.args_text.bind("<Command-Key-a>", self.args_select_all)
        # else:
        #     self.args_text.bind("<Control-Key-a>", self.args_select_all)

        buttonsFrame = ttk.Frame(overall_frame, padding='0.1i')
        self.run_button = ttk.Button(buttonsFrame,
                                     text="Run",
                                     width=8,
                                     command=self.run_tool)
        # self.run_button.pack(pady=10, padx=10)
        self.run_button.grid(row=0, column=0)
        self.quitButton = ttk.Button(buttonsFrame,
                                     text="Cancel",
                                     width=8,
                                     command=self.cancel_operation)
        self.quitButton.grid(row=0, column=1)
        buttonsFrame.grid(row=3, column=0, sticky=tk.E)

        output_frame = ttk.Frame(overall_frame, padding='0.1i')
        outlabel = ttk.Label(output_frame, text="Output:", justify=tk.LEFT)
        outlabel.grid(row=0, column=0, sticky=tk.NW)
        k = wbt.tool_help(self.tool_name)
        self.out_text = ScrolledText(output_frame,
                                     width=63,
                                     height=10,
                                     wrap=tk.NONE,
                                     padx=7,
                                     pady=7)
        self.out_text.insert(tk.END, k)
        self.out_text.grid(row=1, column=0, sticky=tk.NSEW)
        self.out_text.columnconfigure(0, weight=1)
        output_frame.grid(row=4, column=0, sticky=tk.NSEW)
        output_frame.columnconfigure(0, weight=1)

        # Add the binding
        if _platform == "darwin":
            self.out_text.bind("<Command-Key-a>", self.select_all)
            # self.out_text.bind("<Command-Key-A>", self.select_all)
        else:
            self.out_text.bind("<Control-Key-a>", self.select_all)

        progress_frame = ttk.Frame(overall_frame, padding='0.1i')
        self.progress_label = ttk.Label(progress_frame,
                                        text="Progress:",
                                        justify=tk.LEFT)
        self.progress_label.grid(row=0, column=0, sticky=tk.E, padx=5)
        self.progress_var = tk.DoubleVar()
        self.progress = ttk.Progressbar(progress_frame,
                                        orient="horizontal",
                                        variable=self.progress_var,
                                        length=200,
                                        maximum=100)
        self.progress.grid(row=0, column=1, sticky=tk.E)
        progress_frame.grid(row=5, column=0, sticky=tk.E)

        overall_frame.grid(row=0, column=1, sticky=tk.NSEW)

        overall_frame.columnconfigure(0, weight=1)
        toplevel_frame.columnconfigure(0, weight=1)
        toplevel_frame.columnconfigure(1, weight=4)
        # self.pack(fill=tk.BOTH, expand=1)
        # toplevel_frame.columnconfigure(0, weight=1)
        # toplevel_frame.rowconfigure(0, weight=1)

        toplevel_frame.grid(row=0, column=0, sticky=tk.NSEW)

        # Select the appropriate tool, if specified, otherwise the first tool
        self.tools_listbox.select_set(selected_item)
        self.tools_listbox.event_generate("<<ListboxSelect>>")
        self.tools_listbox.see(selected_item)

        menubar = tk.Menu(self)
        filemenu = tk.Menu(menubar, tearoff=0)
        filemenu.add_command(label="Locate WhiteboxTools exe",
                             command=self.select_exe)
        # filemenu.add_command(label="Set Working Directory", command=self.wd.select_file)
        filemenu.add_command(label="Refresh Tools", command=self.refresh_tools)
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=self.quit)
        menubar.add_cascade(label="File", menu=filemenu)

        editmenu = tk.Menu(menubar, tearoff=0)
        editmenu.add_command(
            label="Cut",
            command=lambda: self.focus_get().event_generate("<<Cut>>"))
        editmenu.add_command(
            label="Copy",
            command=lambda: self.focus_get().event_generate("<<Copy>>"))
        editmenu.add_command(
            label="Paste",
            command=lambda: self.focus_get().event_generate("<<Paste>>"))

        menubar.add_cascade(label="Edit ", menu=editmenu)

        helpmenu = tk.Menu(menubar, tearoff=0)
        helpmenu.add_command(label="About", command=self.help)

        helpmenu.add_command(label="License", command=self.license)

        menubar.add_cascade(label="Help ", menu=helpmenu)

        self.master.config(menu=menubar)
コード例 #26
0
ファイル: FirstPython.py プロジェクト: h-ueno2/PythonPractice
def on_clicked():
    print("ボタンが押された!")


window = tkinter.Tk()
label = tkinter.Label(window, text="サンプル")
label.pack()  # ---(1)
button = tkinter.Button(window, text="ボタンです。押してください", command=on_clicked)
button.pack()

tkinter.Button(window, text="ボタン").pack()
tkinter.Checkbutton(window, text="チェックボタン").pack()

entry = tkinter.Entry(window)
entry.insert(tkinter.END, "エントリ")
entry.pack()

frame = tkinter.LabelFrame(window, text="ラベル付きフレーム")
frame.pack()
tkinter.Label(frame, text="ラベル").pack()

listbox = tkinter.Listbox(window, height=3)
listbox.insert(tkinter.END, "リストボックス")
listbox.insert(tkinter.END, "項目2")
listbox.pack()

tkinter.Scale(window, orient=tkinter.HORIZONTAL).pack()
tkinter.Spinbox(window).pack()

window.mainloop()
コード例 #27
0
def launch_jinjatool():
    global win_jinjatool_main, chk_selectcommon, chk_selectnames, chk_selectpolicybindings
    global chk_selectinterfaces
    global input_frame, options_frame, operation_frame, output_frame
    global lst_Listbox_data

    win_jinjatool_main = tk.Toplevel()
    chk_selectcommon = tk.IntVar()
    chk_selectnames = tk.IntVar()
    chk_selectpolicybindings = tk.IntVar()
    chk_selectinterfaces = tk.IntVar()
    input_frame = tk.Frame(win_jinjatool_main)
    options_frame = tk.Frame(win_jinjatool_main,
                             bd="2",
                             highlightbackground="black",
                             highlightthickness=1)
    operation_frame = tk.Frame(win_jinjatool_main)
    output_frame = tk.Frame(win_jinjatool_main)
    lst_Listbox_data = tk.Listbox(operation_frame, selectmode=tk.MULTIPLE)

    win_jinjatool_main.title('Jinja TOOL')
    win_jinjatool_main.geometry('900x700')  # Size 200, 200

    lbl_api = tk.Label(input_frame, text=" ")
    btn_openfile = tk.Button(input_frame,
                             text='Select YML File to OPEN',
                             command=open_yml)
    btn_openapi = tk.Button(
        input_frame,
        text='Load YML via API',
        command=open_api,
    )  ###state="disabled"

    btn_convert = tk.Button(output_frame,
                            text='Convert to JINJA',
                            command=replace_selected)
    btn_revert = tk.Button(output_frame,
                           text='Revert Selection to YAML',
                           command=revert_selected)
    btn_save = tk.Button(output_frame,
                         text='Save JINJA and CSV Parameters File',
                         command=save_jinja)

    scrollbar = tk.Scrollbar(operation_frame)
    lst_Listbox_data.config(yscrollcommand=scrollbar.set)
    scrollbar.config(command=lst_Listbox_data.yview)
    lst_Listbox_data.bind("<Double-Button-1>", modify_item_jinja_var)

    input_frame.pack(fill="both")
    btn_openfile.pack(side="left", fill="both")
    btn_openapi.pack(side="right", fill="both")
    lbl_api.pack(side="right", fill="both")

    options_frame.pack(fill="both")
    lbl_labelcheckdescription = tk.Label(options_frame, text="Quick Select: ")
    lbl_labelcheckdescription.pack(side="left", fill="y")
    chk_chkselectcommon = tk.Checkbutton(options_frame,
                                         text='Site Location ',
                                         command=select_common_yml_params,
                                         variable=chk_selectcommon)
    chk_chkselectcommon.pack(side="left", fill="y", padx=15)
    chk_chkselectnames = tk.Checkbutton(options_frame,
                                        text='Site/Element Names',
                                        command=select_names,
                                        variable=chk_selectnames)
    chk_chkselectnames.pack(side="left", fill="y", padx=15)
    chk_chkpolicybindings = tk.Checkbutton(options_frame,
                                           text='Policy Bindings',
                                           command=select_common_policy_params,
                                           variable=chk_selectpolicybindings)
    chk_chkpolicybindings.pack(side="left", fill="y", padx=15)

    chk_chkselectinterfaces = tk.Checkbutton(options_frame,
                                             text='Interfaces',
                                             command=select_names,
                                             variable=chk_selectinterfaces)
    chk_chkselectinterfaces.pack(side="left", fill="y", padx=15)

    operation_frame.pack(expand=1, fill="both")
    scrollbar.pack(side="right", fill="y")
    lst_Listbox_data.pack(expand=1, fill="both", side="left")

    output_frame.pack(fill="both")
    btn_convert.pack(side="left", )
    btn_revert.pack(side="left", )
    btn_save.pack(side="right")

    win_jinjatool_main.lift(aboveThis=win_launchermain)
    win_jinjatool_main.grab_set()
コード例 #28
0
# Select all files in listox
w_b_select_all = Button(w_col_1, text='Select all', width=13)
w_b_select_all.grid(row=2, column=0, padx=5, pady=5)

# Import Button
w_b_import = Button(w_col_0,
                    text='Import',
                    width=13,
                    command=m.files_to_columns)
w_b_import.grid(row=2, column=1, padx=5, pady=5)

# Files listbox
w_lb_files_var = tk.StringVar()
w_lb_files = tk.Listbox(w_col_0,
                        listvariable=w_lb_files_var,
                        selectmode=tk.MULTIPLE,
                        height=29,
                        width=30,
                        exportselection=False)
w_lb_files.grid(row=3,
                column=0,
                columnspan=2,
                rowspan=16,
                padx=5,
                pady=5,
                sticky=(N, S, E, W))

# Col 3
# Select all columns in listbox
w_b_select_all = Button(w_col_1, text='Select all', width=28)
w_b_select_all.grid(row=0, column=3, padx=5, pady=5, columnspan=2)
コード例 #29
0
ファイル: FileClient08.py プロジェクト: wuguipengpy/python
from tkinter import filedialog    # 用于弹出选择对话框

IP = '127.0.0.1'
PORT2 = 50008    # 聊天室的端口为50008
s = socket.socket( socket.AF_INET, socket.SOCK_STREAM )
s.connect((IP, PORT2))
label = ''# 显示路径的标签

## 创建窗口
ftp = tkinter.Tk()
ftp.title('文件')
ftp['height'] = 400
ftp['width'] = 300

# 创建列表框
list2 = tkinter.Listbox(ftp)
list2.place(x=5, y=20, width=290, height=330)

# 将接收到的目录文件列表打印出来(dir), 显示在列表框中, 在pwd函数中调用
def recvList(enter, lu):
    s.send(enter.encode())
    data = s.recv(4096)  
    data = json.loads(data.decode())
    list2.delete(0, tkinter.END)  # 清空列表框
    lu = lu.split('\\')
    if len(lu) != 1:
        list2.insert(tkinter.END, ' 返回上一级目录')
        list2.itemconfig(0, fg='green')
    for i in range(len(data)):
        list2.insert(tkinter.END, (' '+data[i]))
        if not '.' in data[i]:
コード例 #30
0
    def __init__(self, sources_list=None):
        self._root = tkinter.Tk()
        self._list = tkinter.Listbox(self._root, width=50)
        self._add_files(sources_list)
        #self._list.insert(0, sources_list)
        self._list.grid(row=0, column=0, columnspan=3)
        self._addfiles_btn = tkinter.ttk.Button(self._root,
                                                text="Add files",
                                                command=self._add_files)
        self._addfiles_btn.grid(row=1, column=0, columnspan=3)

        self._mode_selector_header = tkinter.Label(self._root,
                                                   text="Select convert mode:")
        self._mode_selector_header.grid(row=2,
                                        column=0,
                                        sticky="w",
                                        columnspan=2)
        self._mode = tkinter.IntVar(self._root, 1)
        self._CRF_radio_btn = tkinter.Radiobutton(self._root,
                                                  text="CRF:",
                                                  variable=self._mode,
                                                  value=0)
        self._CRF_radio_btn.grid(row=3, column=0, sticky="w")
        self._CRF_value_field = tkinter.Entry(self._root)
        self._CRF_value_field.insert(0, "18")
        self._CRF_value_field.grid(row=3, column=1, sticky="w")
        self._2pass_radio_btn = tkinter.Radiobutton(
            self._root,
            text="2 pass bitrate kbps:",
            variable=self._mode,
            value=1)
        self._2pass_radio_btn.grid(row=4, column=0, sticky="w")
        self._2pass_bitrate = tkinter.Entry(self._root)
        self._2pass_bitrate.insert(0, "5000")
        self._2pass_bitrate.grid(row=4, column=1, sticky="w")

        self._vcodec_label = tkinter.Label(self._root, text="Video codec:")
        self._vcodec_label.grid(row=5, column=0, sticky="w")
        self._vcodec_field = tkinter.ttk.Combobox(
            self._root, values=['libx264', 'libx265', 'libvpx-vp9'])
        self._vcodec_field.current(0)
        self._vcodec_field.grid(row=5, column=1, sticky="w")

        self._preset_label = tkinter.Label(
            self._root, text="Quality level (encoding time):")
        self._preset_label.grid(row=6, column=0, sticky="w")
        self._preset_field = tkinter.ttk.Combobox(self._root,
                                                  values=[
                                                      'ultrafast', 'superfast',
                                                      'veryfast', 'faster',
                                                      'fast', 'medium', 'slow',
                                                      'slower', 'veryslow',
                                                      'placebo'
                                                  ])
        self._preset_field.current(8)
        self._preset_field.grid(row=6, column=1)
        self._convert_btn = tkinter.ttk.Button(self._root,
                                               text="Convert",
                                               command=self._start_convert)
        self._convert_btn.grid(row=7, column=0, columnspan=3)
        self._progress = tkinter.ttk.Progressbar(self._root, length=400)
        self._progress.grid(row=8, column=0, columnspan=3)
        self._root.maxsize(*SIZE)
        self._root.minsize(*SIZE)
        self._root.mainloop()