Пример #1
0
    def __init__(self, controller, parent):
        self.controller = controller

        self.creationPage = ttk.Frame(parent, relief=tk.SUNKEN, padding=5)
        self.creationPage.grid_columnconfigure(0, weight=2, uniform="x")
        self.creationPage.grid_columnconfigure(1, weight=2, uniform="x")
        self.creationPage.grid_columnconfigure(2, weight=3, uniform="x")
        self.creationPage.grid_rowconfigure(1, weight=1)
        self.creationPage.grid(row=0, column=0, padx=5, sticky="NSEW")

        #
        # Left Frame
        #
        self.summaryFrame = ttk.Frame(self.creationPage,
                                      relief=tk.RAISED,
                                      padding=5)
        self.summaryFrame.grid(row=0, column=0, padx=10, sticky="NSEW")
        self.summaryFrame.grid_columnconfigure(1, weight=1)

        # Name
        tk.Label(self.summaryFrame, text="Character Name: ").grid(row=0,
                                                                  column=0)
        tk.Entry(self.summaryFrame,
                 textvariable=self.controller.charName).grid(row=0,
                                                             column=1,
                                                             pady=10,
                                                             sticky="EW")

        # Race
        tk.Label(self.summaryFrame, text="Race:").grid(row=1, column=0, pady=8)
        self.racesMenu = tk.OptionMenu(self.summaryFrame, self.controller.race,
                                       *self.controller.races)
        self.racesMenu.config(width=25, fg="red")
        self.racesMenu.grid(row=1, column=1)
        self.racesMenu.config(font=('Helvetica', 10), highlightthickness=0)

        # Racial Ability Bonus
        tk.Label(self.summaryFrame,
                 text="Racial ability bonus: ").grid(row=2,
                                                     column=0,
                                                     pady=8,
                                                     padx=10)
        self.abilityMenu = tk.OptionMenu(self.summaryFrame,
                                         self.controller.bonusAbility,
                                         *self.controller.ABILITY_BONUS)
        self.abilityMenu.config(width=25, fg="red")
        self.abilityMenu.grid(row=2, column=1)
        self.abilityMenu.config(font=('Helvetica', 10), highlightthickness=0)
        self.abilityMenu.grid_remove()

        # Alignment
        tk.Label(self.summaryFrame, text="Alignment: ").grid(row=3,
                                                             column=0,
                                                             pady=8,
                                                             padx=10)
        self.alignmentMenu = tk.OptionMenu(self.summaryFrame,
                                           self.controller.alignment,
                                           *self.controller.ALIGNMENTS)
        self.alignmentMenu.config(width=25)
        self.alignmentMenu.grid(row=3, column=1)
        self.alignmentMenu.config(font=('Helvetica', 10), highlightthickness=0)

        # Deity
        tk.Label(self.summaryFrame, text="Deity: ").grid(row=4,
                                                         column=0,
                                                         pady=8,
                                                         padx=10)
        self.deityMenu = tk.OptionMenu(self.summaryFrame,
                                       self.controller.deity,
                                       *self.controller.deities)
        self.deityMenu.config(width=25)
        self.deityMenu.grid(row=4, column=1, columnspan=3)
        self.deityMenu.config(font=('Helvetica', 10), highlightthickness=0)

        # Favorite Class
        tk.Label(self.summaryFrame, text="Favorite Class: ").grid(row=5,
                                                                  column=0,
                                                                  pady=8,
                                                                  padx=10)
        self.favClassMenu = tk.OptionMenu(self.summaryFrame,
                                          self.controller.favClass,
                                          *self.controller.classes)
        self.favClassMenu.config(width=25)
        self.favClassMenu.grid(row=5, column=1)
        self.favClassMenu.config(font=('Helvetica', 10), highlightthickness=0)
        self.favClassMenu.grid_remove()

        #
        # Ability Advancement
        #
        self.advancementFrame = ttk.Frame(self.creationPage,
                                          relief=tk.RAISED,
                                          padding=5)
        self.advancementFrame.grid(row=1,
                                   column=0,
                                   padx=10,
                                   pady=10,
                                   sticky="NEW")
        self.advancementFrame.grid_columnconfigure(1, weight=1)

        tk.Label(self.advancementFrame,
                 text="Ability Advancement").grid(row=0,
                                                  column=0,
                                                  columnspan=2,
                                                  sticky="EW")
        tk.Label(self.advancementFrame, text="Level").grid(row=1,
                                                           column=0,
                                                           padx=10,
                                                           pady=10)
        tk.Label(self.advancementFrame, text="Ability").grid(row=1,
                                                             column=1,
                                                             padx=10,
                                                             pady=10)

        #
        # Center Frame
        #
        self.statFrame = ttk.Frame(self.creationPage,
                                   relief=tk.RAISED,
                                   padding=5)
        self.statFrame.grid(row=0, column=1, padx=10, sticky="NEW")
        self.statFrame.grid_columnconfigure(0, weight=1)
        self.statFrame.grid_columnconfigure(1, weight=1)

        # Ability Scores
        tk.Label(self.statFrame, text="Ability Scores").grid(row=0,
                                                             column=0,
                                                             columnspan=2,
                                                             sticky="EW")

        self.abilityFrame = ttk.Frame(self.statFrame)
        self.abilityFrame.grid(row=1, column=0, columnspan=2, sticky="EW")
        self.abilityFrame.grid_columnconfigure(0, weight=1)
        self.abilityFrame.grid_columnconfigure(1, weight=1)
        self.abilityFrame.grid_columnconfigure(2, weight=1)
        self.abilityFrame.grid_columnconfigure(3, weight=1)
        self.abilityFrame.grid_columnconfigure(4, weight=1)
        self.abilityFrame.grid_columnconfigure(5, weight=1)

        # STRENGTH
        tk.Label(self.abilityFrame,
                 textvariable=self.controller.strBonusStr,
                 relief=tk.SUNKEN).grid(row=0, column=0, columnspan=2, pady=10)
        tk.Label(self.abilityFrame,
                 textvariable=self.controller.getModifiableValue("str"),
                 bg="white",
                 width=2).grid(row=1, column=0, sticky="E", padx=5)
        self.strButtons = ttk.Frame(self.abilityFrame)
        self.strButtons.grid(row=1, column=1, sticky="W")
        self.createStatsButtons(self.strButtons, "str")

        # DEXTERITY
        tk.Label(self.abilityFrame,
                 textvariable=self.controller.dexBonusStr,
                 relief=tk.SUNKEN).grid(row=0, column=2, columnspan=2, pady=10)
        tk.Label(self.abilityFrame,
                 textvariable=self.controller.getModifiableValue("dex"),
                 bg="white",
                 width=2).grid(row=1, column=2, sticky="E", padx=5)
        self.dexButtons = ttk.Frame(self.abilityFrame)
        self.dexButtons.grid(row=1, column=3, sticky="W")
        self.createStatsButtons(self.dexButtons, "dex")

        # CONSTITUTION
        tk.Label(self.abilityFrame,
                 textvariable=self.controller.conBonusStr,
                 relief=tk.SUNKEN).grid(row=0, column=4, columnspan=2, pady=10)
        tk.Label(self.abilityFrame,
                 textvariable=self.controller.getModifiableValue("con"),
                 bg="white",
                 width=2).grid(row=1, column=4, sticky="E", padx=5)
        self.conButtons = ttk.Frame(self.abilityFrame)
        self.conButtons.grid(row=1, column=5, sticky="W")
        self.createStatsButtons(self.conButtons, "con")

        # INTELLIGENCE
        tk.Label(self.abilityFrame,
                 textvariable=self.controller.intBonusStr,
                 relief=tk.SUNKEN).grid(row=2, column=0, columnspan=2, pady=10)
        tk.Label(self.abilityFrame,
                 textvariable=self.controller.getModifiableValue("int"),
                 bg="white",
                 width=2).grid(row=3, column=0, sticky="E", padx=5)
        self.intButtons = ttk.Frame(self.abilityFrame)
        self.intButtons.grid(row=3, column=1, sticky="W")
        self.createStatsButtons(self.intButtons, "int")

        # WISDOM
        tk.Label(self.abilityFrame,
                 textvariable=self.controller.wisBonusStr,
                 relief=tk.SUNKEN).grid(row=2, column=2, columnspan=2, pady=10)
        tk.Label(self.abilityFrame,
                 textvariable=self.controller.getModifiableValue("wis"),
                 bg="white",
                 width=2).grid(row=3, column=2, sticky="E", padx=5)
        self.wisButtons = ttk.Frame(self.abilityFrame)
        self.wisButtons.grid(row=3, column=3, sticky="W")
        self.createStatsButtons(self.wisButtons, "wis")

        # CHARISMA
        tk.Label(self.abilityFrame,
                 textvariable=self.controller.chaBonusStr,
                 relief=tk.SUNKEN).grid(row=2, column=4, columnspan=2, pady=10)
        tk.Label(self.abilityFrame,
                 textvariable=self.controller.getModifiableValue("cha"),
                 bg="white",
                 width=2).grid(row=3, column=4, sticky="E", padx=5)
        self.chaButtons = ttk.Frame(self.abilityFrame)
        self.chaButtons.grid(row=3, column=5, sticky="W")
        self.createStatsButtons(self.chaButtons, "cha")

        # BUY POINTS
        tk.Label(self.statFrame, text="Purchase Mode:").grid(row=2,
                                                             column=0,
                                                             pady=20)

        self.purchaseModeMenu = tk.OptionMenu(self.statFrame,
                                              self.controller.purchaseMode,
                                              *self.controller.PURCHASE_MODES)
        self.purchaseModeMenu.grid(row=2, column=1)
        self.purchaseModeMenu.config(width=25,
                                     font=('Helvetica', 10),
                                     highlightthickness=0)
        tk.Label(self.statFrame, text="Buy Points spent:").grid(row=3,
                                                                column=0)
        self.buyPointsLabel = tk.Label(self.statFrame,
                                       textvariable=self.controller.buyPoints)
        self.buyPointsLabel.grid(row=3, column=1)

        # Languages
        self.languageFrame = ttk.Frame(self.creationPage,
                                       relief=tk.RAISED,
                                       padding=5)
        self.languageFrame.grid(row=1,
                                column=1,
                                rowspan=2,
                                padx=10,
                                pady=10,
                                sticky="NEW")
        self.languageFrame.grid_columnconfigure(0, weight=1)

        tk.Label(self.languageFrame, text="Languages").grid(row=0,
                                                            column=0,
                                                            sticky="EW")
        self.addLanguageButton = tk.Button(
            self.languageFrame,
            text="Add",
            font=("helvetica", 10),
            command=self.controller.createLanguageWindow)
        self.addLanguageButton.grid(row=0, column=1, padx=10)
        self.addLanguageButton.config(state="disabled")

        self.knownLanguagesFrame = ttk.Frame(self.languageFrame, padding=5)
        self.knownLanguagesFrame.grid(row=1,
                                      column=0,
                                      columnspan=2,
                                      padx=5,
                                      sticky="EW")

        #
        # Right Frame
        #
        self.classFrame = ttk.Frame(self.creationPage,
                                    relief=tk.RAISED,
                                    padding=5)
        self.classFrame.grid(row=0, column=2, rowspan=3, padx=10, sticky="NEW")
        self.classFrame.grid_columnconfigure(1, weight=1)

        # Class
        tk.Label(self.classFrame, text="Class: ").grid(row=0, column=0, pady=8)
        self.classMenu = tk.OptionMenu(self.classFrame,
                                       self.controller.charClass,
                                       *self.controller.classes)
        self.classMenu.config(width=25)
        self.classMenu.grid(row=0, column=1, padx=10)
        self.classMenu.config(font=('Helvetica', 12), highlightthickness=0)

        tk.Label(self.classFrame, text="Level: ").grid(row=1, column=0)

        self.addLevelFrame = ttk.Frame(self.classFrame)
        self.addLevelFrame.grid(row=1, column=1, pady=8)
        tk.Label(self.addLevelFrame,
                 textvariable=self.controller.levelNb,
                 bg="white",
                 width=2).grid(row=0, column=0, padx=10)

        self.lvlButtons = ttk.Frame(self.addLevelFrame)
        self.lvlButtons.grid(row=0, column=1)
        tk.Button(self.lvlButtons,
                  text="▲",
                  font=("helvetica", 6),
                  width=1,
                  command=lambda: self.controller.setLevelNb(1)).grid(row=0,
                                                                      column=0)
        tk.Button(self.lvlButtons,
                  text="▼",
                  font=("helvetica", 6),
                  width=1,
                  command=lambda: self.controller.setLevelNb(-1)).grid(
                      row=1, column=0)
        self.addLevelsButton = tk.Button(self.addLevelFrame,
                                         text="Add level(s)",
                                         font=('Helvetica', 12),
                                         command=self.controller.addLevels)
        self.addLevelsButton.grid(row=0, column=2, padx=5, sticky="W")
        self.addLevelsButton.config(state="disabled")

        self.charClassFrame = ttk.Frame(self.classFrame)
        self.charClassFrame.grid(row=2, column=0, columnspan=2, sticky="NEW")

        # Total HP
        self.hpFrame = ttk.Frame(self.creationPage,
                                 relief=tk.RAISED,
                                 padding=5)
        self.hpFrame.grid(row=2, column=2, padx=10, sticky="SEW")
        self.hpFrame.grid_columnconfigure(1, weight=1)

        tk.Label(self.hpFrame, text="Hit Point(s):").grid(row=1, column=0)
        tk.Label(self.hpFrame,
                 textvariable=self.controller.getModifiableValue("hp")).grid(
                     row=1, column=1)

        self.creationPage.update_idletasks()
Пример #2
0
    def __init__(self, tl, chief, ttl, h, cols=None, ipath=None, resize=False):
        """
         initialize
         tl: the Toplevel of this panel
         chief: the master/controlling panel
         ttl: title to display
         h: # of lines to configure the treeview's height
         cols: a list of tuples col<i> =(l,w,t) where:
           l is the text to display in the header
           w is the desired width of the column in pixels
           t is the type of data in the column
         ipath: path of appicon
         resize: allow Panel to be resized by user
        """
        SlavePanel.__init__(self, tl, chief, ttl, ipath, resize)

        # create and allow derived classes to setup top frame
        frmT = ttk.Frame(self)
        if self.topframe(frmT): frmT.grid(row=0, column=0, sticky='nwse')

        # setup the main frame (NOTE: we set the row to 1 regardless of topframe)
        frmM = ttk.Frame(self)
        frmM.grid(row=1, column=0, sticky='nwse')

        # create a multi-column Tree
        self._tree = ttk.Treeview(frmM)
        self._tree.grid(row=0, column=0, sticky='nwse')
        self._tree.config(height=h)
        self._tree.config(selectmode='extended')

        # with attached horizontal/vertical scrollbars
        vscroll = ttk.Scrollbar(frmM,
                                orient=tk.VERTICAL,
                                command=self._tree.yview)
        vscroll.grid(row=0, column=1, sticky='ns')
        self._tree['yscrollcommand'] = vscroll.set
        hscroll = ttk.Scrollbar(frmM,
                                orient=tk.HORIZONTAL,
                                command=self._tree.xview)
        hscroll.grid(row=1, column=0, sticky='ew')
        self._tree['xscrollcommand'] = hscroll.set

        # configure the headers
        self._ctypes = []  # the type in this column
        self._tree['columns'] = [t[0] for t in cols]
        for i in xrange(len(cols)):
            # for each one set the column to the use specified width (or 0)
            # and set the text for each header if present as well as the sort
            # functionality (the sort functionality is set in a separate fct)
            self._ctypes.append(cols[i][2])
            try:
                w = max(lenpix(cols[i][0]), cols[i][1])
                if w is None: w = 0
            except:
                w = 0
            self._tree.column(i, width=w, anchor=tk.CENTER)
            if cols[i][0] != '': self._makesort(i, cols[i][0])

        # bind right click on the tree
        self._tree.bind('<Button-3>', self.treerc)
        self._tree.bind('<Control-a>', self.treeca)

        # allow a bottom frame
        frmB = ttk.Frame(self)
        if self.bottomframe(frmB): frmB.grid(row=2, column=0, sticky='nwse')
 def wrapped(cls, master, **kw):
     container = ttk.Frame(master)
     return func(cls, container, **kw)
Пример #4
0
    def __init__(self, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#ececec'  # Closest X11 color: 'gray92'
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.configure('.', font="TkDefaultFont")
        self.style.map('.',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])

        top.geometry("880x550")
        top.minsize(1, 1)
        top.maxsize(1351, 738)
        top.resizable(1, 1)
        top.title("Cashier")
        top.configure(highlightcolor="black")

        self.Frame_Inputan = ttk.Frame(top)
        self.Frame_Inputan.place(relx=0.013,
                                 rely=0.022,
                                 relheight=0.239,
                                 relwidth=0.981)
        self.Frame_Inputan.configure(relief='flat')
        self.Frame_Inputan.configure(borderwidth="2")
        self.Frame_Inputan.configure(relief="flat")

        self.lf_name = ttk.Labelframe(self.Frame_Inputan)
        self.lf_name.place(relx=0.012,
                           rely=0.15,
                           relheight=0.608,
                           relwidth=0.311)
        self.lf_name.configure(relief='')
        self.lf_name.configure(text='''Item''')

        self.e_name = ttk.Entry(self.lf_name)
        self.e_name.place(relx=0.041,
                          rely=0.384,
                          relheight=0.384,
                          relwidth=0.884,
                          bordermode='ignore')
        self.e_name.configure(textvariable=test_support.ev_nama)
        self.e_name.configure(background="#727272")
        self.e_name.configure(takefocus="")
        self.e_name.configure(cursor="xterm")

        self.lf_amount = ttk.Labelframe(self.Frame_Inputan)
        self.lf_amount.place(relx=0.346,
                             rely=0.15,
                             relheight=0.608,
                             relwidth=0.311)
        self.lf_amount.configure(relief='')
        self.lf_amount.configure(text='''Amount''')

        self.e_amount = ttk.Entry(self.lf_amount)
        self.e_amount.place(relx=0.041,
                            rely=0.384,
                            relheight=0.384,
                            relwidth=0.888,
                            bordermode='ignore')
        self.e_amount.configure(textvariable=test_support.ev_jumlah)
        self.e_amount.configure(background="#727272")
        self.e_amount.configure(takefocus="")
        self.e_amount.configure(cursor="xterm")

        self.lf_price = ttk.Labelframe(self.Frame_Inputan)
        self.lf_price.place(relx=0.683,
                            rely=0.15,
                            relheight=0.608,
                            relwidth=0.309)
        self.lf_price.configure(relief='')
        self.lf_price.configure(text='''Price''')

        self.e_price = ttk.Entry(self.lf_price)
        self.e_price.place(relx=0.041,
                           rely=0.384,
                           relheight=0.384,
                           relwidth=0.888,
                           bordermode='ignore')
        self.e_price.configure(textvariable=test_support.ev_harga)
        self.e_price.configure(background="#727272")
        self.e_price.configure(takefocus="")
        self.e_price.configure(cursor="xterm")

        self.frame_btn = ttk.Frame(top)
        self.frame_btn.place(relx=0.841,
                             rely=0.299,
                             relheight=0.687,
                             relwidth=0.151)
        self.frame_btn.configure(relief='groove')
        self.frame_btn.configure(borderwidth="2")
        self.frame_btn.configure(relief="groove")

        self.btn_add = ttk.Button(self.frame_btn)
        self.btn_add.place(relx=0.075, rely=0.029, height=28, width=103)
        self.btn_add.configure(command=test_support.add)
        self.btn_add.configure(takefocus="")
        self.btn_add.configure(text='''Add''')
        self.btn_add.configure(cursor="X_cursor")

        self.btn_remove = ttk.Button(self.frame_btn)
        self.btn_remove.place(relx=0.083, rely=0.165, height=28, width=103)
        self.btn_remove.configure(command=test_support.remove)
        self.btn_remove.configure(takefocus="")
        self.btn_remove.configure(text='''Remove''')
        self.btn_remove.configure(cursor="X_cursor")

        self.btn_exp = ttk.Button(self.frame_btn)
        self.btn_exp.place(relx=0.083, rely=0.296, height=28, width=103)
        self.btn_exp.configure(command=test_support.export)
        self.btn_exp.configure(takefocus="")
        self.btn_exp.configure(text='''Export''')
        self.btn_exp.configure(cursor="X_cursor")

        self.btn_exit = ttk.Button(self.frame_btn)
        self.btn_exit.place(relx=0.075, rely=0.899, height=28, width=113)
        self.btn_exit.configure(command=test_support.exit)
        self.btn_exit.configure(takefocus="")
        self.btn_exit.configure(text='''Exit''')
        self.btn_exit.configure(cursor="X_cursor")

        self.lt_tota = ttk.Labelframe(self.frame_btn)
        self.lt_tota.place(relx=0.075,
                           rely=0.696,
                           relheight=0.159,
                           relwidth=0.827)
        self.lt_tota.configure(relief='')
        self.lt_tota.configure(text='''Total''')
        self.lt_tota.configure(takefocus="0")

        self.l_total = tk.Label(self.lt_tota)
        self.l_total.place(relx=0.091,
                           rely=0.364,
                           height=21,
                           width=89,
                           bordermode='ignore')
        self.l_total.configure(activebackground="#f9f9f9")
        self.l_total.configure(textvariable=test_support.ev_total)

        self.frame_treeview = ttk.Frame(top)
        self.frame_treeview.place(relx=0.013,
                                  rely=0.311,
                                  relheight=0.677,
                                  relwidth=0.811)
        self.frame_treeview.configure(relief="flat")
        self.frame_treeview.configure(borderwidth="2")
        self.frame_treeview.configure(relief="flat")
        self.frame_treeview.configure(takefocus="0")

        self.style.configure('Treeview', font="TkDefaultFont")
        self.trv = ScrolledTreeView(self.frame_treeview)
        self.trv.place(relx=0.0, rely=0.0, relheight=0.971, relwidth=0.98)
        self.trv.configure(columns="name Col1 Col2 Col3")
        self.trv.configure(takefocus="0")
        # build_treeview_support starting.
        self.trv.heading("#0", text="•")
        self.trv.heading("#0", anchor="center")
        self.trv.column("#0", width="30")
        self.trv.column("#0", minwidth="10")
        self.trv.column("#0", stretch="1")
        self.trv.column("#0", anchor="w")
        self.trv.heading("name", text="Item")
        self.trv.heading("name", anchor="center")
        self.trv.column("name", width="176")
        self.trv.column("name", minwidth="20")
        self.trv.column("name", stretch="1")
        self.trv.column("name", anchor="center")
        self.trv.heading("Col1", text="Amount")
        self.trv.heading("Col1", anchor="center")
        self.trv.column("Col1", width="146")
        self.trv.column("Col1", minwidth="20")
        self.trv.column("Col1", stretch="1")
        self.trv.column("Col1", anchor="e")
        self.trv.heading("Col2", text="Price")
        self.trv.heading("Col2", anchor="center")
        self.trv.column("Col2", width="170")
        self.trv.column("Col2", minwidth="20")
        self.trv.column("Col2", stretch="1")
        self.trv.column("Col2", anchor="e")
        self.trv.heading("Col3", text="Total")
        self.trv.heading("Col3", anchor="center")
        self.trv.column("Col3", width="164")
        self.trv.column("Col3", minwidth="20")
        self.trv.column("Col3", stretch="1")
        self.trv.column("Col3", anchor="e")

        self.TSeparator1 = ttk.Separator(top)
        self.TSeparator1.place(relx=0.013, rely=0.281, relwidth=0.98)
        self.TSeparator1.configure(takefocus="0")

        self.TSeparator2 = ttk.Separator(top)
        self.TSeparator2.place(relx=0.83, rely=0.281, relheight=0.699)
        self.TSeparator2.configure(orient="vertical")
        self.TSeparator2.configure(takefocus="0")
Пример #5
0
 def wrapped(cls, master, **kw):
     container = ttk.Frame(master)
     container.bind('<Enter>', lambda e: _bound_to_mousewheel(e, container))
     container.bind('<Leave>',
                    lambda e: _unbound_to_mousewheel(e, container))
     return func(cls, container, **kw)
Пример #6
0
    def __init__(self, parent, items, items_on, output_var, label_on,
                 label_off):
        """
        :param parent: parent window
        :param items: list of all items
        :param items_on: list of items which are used
        :param output_var: Tkinter StringVar
        :param label_on: label for the list of used items
        :param label_off: label for the list of non used items
        """

        tk.Toplevel.__init__(self, parent)
        self.title('Select items')
        self.resizable(False, False)
        self.bind('<Control-w>', lambda event: cancel())

        self.parent = parent

        self.icon = parent.icon
        self.tk.call('wm', 'iconphoto', self._w, self.icon)

        self.main_frame = ttk.Frame(self)  # Main ttk frame
        self.main_frame.pack(expand=True, fill='both')

        # DOS type choice from previous window
        items_off = list(set(items) - set(items_on))

        # ------------------------------------------------- ITEMS ON ---------------------------------------------------

        self.on_frame = ttk.LabelFrame(self.main_frame, text=label_on)
        self.on_frame.grid(row=0, column=0)

        self.list_on = tk.Listbox(self.on_frame, width=20)
        self.yscrollbar_on = ttk.Scrollbar(self.on_frame, orient='vertical')

        self.list_on.pack(side='left', fill='both', expand=True)
        self.yscrollbar_on.pack(side='right', fill='y')

        self.list_on.config(yscrollcommand=self.yscrollbar_on.set)
        self.yscrollbar_on.config(command=self.list_on.yview)

        [self.list_on.insert('end', f) for f in items_on]

        # -------------------------------------------------- ITEMS OFF -------------------------------------------------

        self.frame_off = ttk.LabelFrame(self.main_frame, text=label_off)
        self.frame_off.grid(row=0, column=2)

        self.list_off = tk.Listbox(
            self.frame_off, width=20)  # list containing element non plotted
        self.yscrollbar_off = ttk.Scrollbar(self.frame_off, orient='vertical')

        self.list_off.pack(side='left', fill='both', expand=True)
        self.yscrollbar_off.pack(side='right', fill='y')

        self.list_off.config(yscrollcommand=self.yscrollbar_off.set)
        self.yscrollbar_off.config(command=self.list_off.yview)

        [self.list_off.insert('end', f) for f in items_off]

        # --------------------------------------------------- BUTTONS --------------------------------------------------

        self.button_frame = ttk.Frame(self.main_frame)
        self.button_frame.grid(row=0, column=1, padx=5)

        def remove_selection():
            """ Remove selected elements in the 'on' list and add them to the 'off' list """
            selection = self.list_on.curselection()
            if len(selection) != 0:
                for selected in selection:
                    items_ids = self.list_on.get(selected)
                    self.list_off.insert(0, items_ids)
                    self.list_on.delete(selected)

        def add_selection():
            """ Add selected elements to the 'on' list and remove them from the 'off' list """
            selection = self.list_off.curselection()
            if len(selection) != 0:
                for selected in selection:
                    items_ids = self.list_off.get(selected)
                    self.list_on.insert(0, items_ids)
                    self.list_off.delete(selected)

        def add_all():
            """ Add all items to the 'on' list and remove them from the 'off' list """
            self.list_off.delete(0, 'end')
            self.list_on.delete(0, 'end')
            [self.list_on.insert(0, f) for f in items]

        def remove_all():
            """ Remove all items from the 'on' list and add them to the 'off' list """
            self.list_on.delete(0, 'end')
            self.list_off.delete(0, 'end')
            [self.list_off.insert(0, f) for f in items]

        ttk.Button(self.button_frame, text='>',
                   command=remove_selection).pack(side='top')
        ttk.Button(self.button_frame, text='>>',
                   command=remove_all).pack(side='top')
        ttk.Button(self.button_frame, text='<',
                   command=add_selection).pack(side='top')
        ttk.Button(self.button_frame, text='<<',
                   command=add_all).pack(side='top')

        def add_selected(event):
            """ Add the selected item to the 'on' list and remove it from the 'off' list when "event" happens """
            widget = event.widget
            widget.curselection()
            add_selection()

        def remove_selected(event):
            """ Add the selected item to the 'off' list and remove it from the 'on' list when "event" happens """
            widget = event.widget
            widget.curselection()
            remove_selection()

        self.list_on.bind(
            '<Double-Button-1>',
            remove_selected)  # remove element when double-clicked
        self.list_off.bind('<Double-Button-1>',
                           add_selected)  # add item when double-clicked

        # ------------------------------------------------ MAIN BUTTONS ------------------------------------------------

        self.main_button_frame = ttk.Frame(self.main_frame)
        self.main_button_frame.grid(row=1, column=0, columnspan=3)

        def save():
            """ Save the choice and close the window """
            choice = list(self.list_on.get(0, 'end'))
            if len(choice) == 0:
                mb.showerror('Error', 'Select at least one item', parent=self)
                return None
            else:
                output_var.set(','.join(choice))
                print(output_var.get())
            self.destroy()

        def cancel():
            """ Save the initial items on and close the window """
            output_var.set(','.join(items_on))
            self.destroy()

        ttk.Button(self.main_button_frame, text='OK',
                   command=save).pack(side='left')
        ttk.Button(self.main_button_frame, text='Cancel',
                   command=cancel).pack(side='right')

        self.protocol('WM_DELETE_WINDOW', cancel)

        ukf.centre_window(self)
Пример #7
0
    def __init__(self, nb, cfg):
        ttk.Frame.__init__(self, nb)  # border=?
        nb.add(self, text=cfg.tabname)  # instead of pack or grid

        wfunc = {
            'tickbox': bvar,
            'int': ivar,
            'float': gvar,
            'text': tvar,
            'file': fvar,
            'choice': cvar,
            'directory': (lambda m, cfg: fvar(m, cfg, dirflag=True))
        }

        cfglabs = ['group', 'grouplab', 'flag', 'label', 'type', 'constraint', \
                        'default', 'mouse_over' ]
        cfglen = len(cfglabs)
        Cfgline = collections.namedtuple('Cfgline', cfglabs)

        self.fv = [
        ]  # Frames vector/list - needed to get pipe-section arguments
        self.pipeline = cfg.run_pipeline

        # read the configuration file for this notebook page and it's associated pipeline code
        # there's a header line, then a series of lines describing the pipeline's parameters.
        # It's a TAB separated file. Fields vary a bit depending on the value type.
        # The differences are handled by the various subclasses of class ifrow above ...
        # the wfunc dict maps row types to subclass constructors

        fs = [(self, cfg.filename)]

        # create a Notebook if its needed for complex options
        nbx = None
        if cfg.subtabs:
            nbx = ttk.Notebook(self)
            for p in cfg.subtabs:
                nbxf = ttk.Frame(nbx)
                nbx.add(nbxf, text=p[0])
                fs.append((nbxf, p[1]))

        # run though the configuration file(s) building the GUI for the pipelines
        # Note: there is still just one frame-vector with argument widgets
        # so just one dictionary is passed as a parameter to the pipeline (there is
        # one Run button for each pipeline)
        for myf, fnx in fs:
            fn = fnx if fnx.startswith(os.path.sep) else os.path.join(cwd, fnx)
            progbar.status("start reading config file:", fn)
            with open(fn) as inp:
                # fldprev is fields from the previous row ... value replace blank fields
                # popts is the pipeline options section being constructed
                fldprev, popts = [None] * cfglen, None
                for lx in inp:
                    lxs = lx.rstrip()
                    if lxs == '' or lxs.lstrip().startswith(
                            '#'):  # drop comment or blank rows
                        continue
                    fld = lxs.split("\t")
                    if len(fld) < cfglen:
                        fld += [None] * (cfglen - len(fld))
                    for i, fx in enumerate(fld):
                        if fx:
                            break
                        fld[i] = fldprev[i]
                    # fld = [fx if fx else prev for fx, prev in zip(fld, fldprev)]
                    assert len(fld) == cfglen, "fld is %r" % fld
                    cx = Cfgline(
                        *tuple(fld))  # make named tuple from config line
                    if not (popts and popts.label == cx.group
                            ):  # column 0? Start a new pipe-section ...
                        popts = pipesect(
                            myf, cx.group,
                            cx.grouplab)  # start a new pipe section
                        self.fv.append(
                            popts
                        )  # add this pipe-section to the frames-vector

                    if cx.type not in wfunc:  # report problem in config file
                        print()
                        print("In config. file:", fn)
                        print("   **** unknown option type:", cx.type)
                        print("type =", cx.type, cx)

                    assert cx.type in wfunc
                    try:
                        wfunc[cx.type](
                            popts,
                            cx)  # generate the parameter line in the GUI
                    except:
                        print("Bad option config:", cx)
                        progbar.status("Configuration error. :(")
                        raise
                    fldprev = fld

            progbar.status("done reading config file:", fn)

        # wait to now to pack the inner notebook ... if it exists.
        if nbx:
            #nbx.pack(fill=tk.BOTH)
            nbx.pack()

        self.runButton = ttk.Button(self,
                                    text="Run",
                                    style="R.TButton",
                                    command=self.run)
        self.runButton.pack(pady=5)
        return
Пример #8
0
    def __init__(self, parent, callback):
        tk.Toplevel.__init__(self, parent)

        self.parent = parent
        self.callback = callback
        self.title('Authentication')

        if parent.winfo_viewable():
            self.transient(parent)

        # position over parent
        if platform != 'darwin' or parent.winfo_rooty(
        ) > 0:  # http://core.tcl.tk/tk/tktview/c84f660833546b1b84e7
            self.geometry("+%d+%d" %
                          (parent.winfo_rootx(), parent.winfo_rooty()))

        # remove decoration
        self.resizable(tk.FALSE, tk.FALSE)
        if platform == 'win32':
            self.attributes('-toolwindow', tk.TRUE)
        elif platform == 'darwin':
            # http://wiki.tcl.tk/13428
            parent.call('tk::unsupported::MacWindowStyle', 'style', self,
                        'utility')

        frame = ttk.Frame(self)
        frame.grid(sticky=tk.NSEW)
        frame.columnconfigure(0, weight=3)
        frame.columnconfigure(2, weight=1)

        ttk.Label(
            frame,
            text=
            _('A verification code has now been sent to the{CR}email address associated with your Elite account.'
              ) +  # Use same text as E:D Launcher's verification dialog
            '\n' + _('Please enter the code into the box below.'),
            anchor=tk.W,
            justify=tk.LEFT).grid(
                columnspan=4, sticky=tk.NSEW
            )  # Use same text as E:D Launcher's verification dialog
        ttk.Label(frame).grid(row=1, column=0)  # spacer
        self.code = ttk.Entry(frame,
                              width=8,
                              validate='key',
                              validatecommand=(self.register(
                                  self.validatecode), '%P', '%d', '%i', '%S'))
        self.code.grid(row=1, column=1)
        self.code.focus_set()
        ttk.Label(frame).grid(row=1, column=2)  # spacer
        self.button = ttk.Button(frame,
                                 text=_('OK'),
                                 command=self.apply,
                                 state=tk.DISABLED)
        self.button.bind("<Return>", lambda event: self.apply())
        self.button.grid(row=1, column=3, sticky=tk.E)

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

        self.protocol("WM_DELETE_WINDOW", self._destroy)

        # wait for window to appear on screen before calling grab_set
        self.parent.wm_attributes(
            '-topmost',
            0)  # needed for dialog to appear ontop of parent on OSX & Linux
        self.wait_visibility()
        self.grab_set()
        #self.wait_window(self)	# causes duplicate events on OSX

        self.bind('<Return>', self.apply)
Пример #9
0
    def __init__(self, parent, title=None):
        Frame.__init__(self, parent)

        self.parent = parent
        loadT1 = StringVar()
        loadT2 = StringVar()
        loadW = StringVar()
        loadV = StringVar()

        if title == None:
            title = "Tie Sweet 1.3"
        self.parent.title(title)

        # Menu Bar
        menubar = Menu(self.parent)
        self.parent.config(menu=menubar)

        # Menu for running suite
        runMenu = Menu(menubar, tearoff=0)
        runMenu.add_command(label="Play Video",
                            underline=0,
                            command=self.OnOpen)
        runMenu.add_command(label="Launch TIE Coder - Client",
                            command=lambda: playerInterface(self, "Client"))
        runMenu.add_command(label="Launch TIE Coder - Counselor",
                            command=lambda: playerInterface(self, "Counselor"))
        runMenu.add_separator()
        runMenu.add_command(label="Save and Quit",
                            command=lambda: saveQuit(self))
        menubar.add_cascade(label="Run", menu=runMenu)

        # Create projMenu Menu List
        projMenu = Menu(menubar, tearoff=0)
        projMenu.add_command(
            label="Resume Project",
            command=lambda: resume(parent, loadT1, loadT2, loadW, loadV))
        projMenu.add_command(
            label="Load Project",
            command=lambda: loadProj(parent, loadT1, loadT2, loadW, loadV))
        projMenu.add_command(label="Save Project",
                             command=lambda: saveProj(parent))
        menubar.add_cascade(label="Project", menu=projMenu)

        # Load in existing files
        loadMenu = Menu(menubar, tearoff=0)
        loadMenu.add_command(
            label="Load Theme - Client",
            command=lambda: loadTheme(parent, "Client", loadT1))
        loadMenu.add_command(
            label="Load Theme - Counselor",
            command=lambda: loadTheme(parent, "Counselor", loadT2))
        loadMenu.add_command(label="Load Workbook",
                             command=lambda: loadExcel(parent, loadW))
        loadMenu.add_command(label="Load Video File",
                             command=lambda: vidLoad(parent, loadV))
        menubar.add_cascade(label="Load Files", menu=loadMenu)

        # Create new files
        newMenu = Menu(menubar, tearoff=0)
        newMenu.add_command(label="Create New Theme",
                            command=lambda: importTheme(parent))
        newMenu.add_command(label="Create New Workbook",
                            command=lambda: createExcel(parent))
        menubar.add_cascade(label="Create Files", menu=newMenu)

        # Show the User which Files are loaded
        self.load1 = Label(self.parent, textvariable=loadT1).pack()
        self.load2 = Label(self.parent, textvariable=loadT2).pack()
        self.load3 = Label(self.parent, textvariable=loadW).pack()
        self.load4 = Label(self.parent, textvariable=loadV).pack()

        # The second panel holds controls
        self.player = None
        self.videopanel = ttk.Frame(self.parent)
        self.canvas = Canvas(self.videopanel).pack(fill=BOTH, expand=1)
        self.videopanel.pack(fill=BOTH, expand=1)

        #Building the control panel
        ctrlpanel = ttk.Frame(self.parent)
        l = Label(ctrlpanel, text="                         ")
        pause = ttk.Button(ctrlpanel, text="Pause", command=self.OnPause)
        play = ttk.Button(ctrlpanel, text="Play", command=self.OnPlay)
        stop = ttk.Button(ctrlpanel, text="Stop", command=self.OnStop)
        volume = ttk.Button(ctrlpanel,
                            text="Mute",
                            command=self.OnToggleVolume)
        pause.pack(side=LEFT)
        play.pack(side=LEFT)
        stop.pack(side=LEFT)
        l.pack(side=LEFT)
        volume.pack(side=LEFT)

        #Building volume slider
        self.volume_var = IntVar()
        self.volume_var.set(100)
        frame1 = ttk.Frame(ctrlpanel)
        self.volslider = Scale(frame1,
                               variable=self.volume_var,
                               command=self.volume_sel,
                               from_=0,
                               to=100,
                               orient=HORIZONTAL,
                               length=100)
        self.volslider.pack()
        self.vol = Label(frame1, text='Volume').pack()
        frame1.pack()
        ctrlpanel.pack(side=BOTTOM)

        l1 = Label(self.parent, text="")
        l1.pack(side=BOTTOM)

        #Building progress bar
        ctrlpanel2 = ttk.Frame(self.parent)
        self.scale_var = DoubleVar()
        self.timeslider_last_val = ""
        self.timeslider = Scale(ctrlpanel2,
                                variable=self.scale_var,
                                command=self.scale_sel,
                                from_=0,
                                to=10000,
                                orient=HORIZONTAL,
                                length=500,
                                tickinterval=60)
        self.timeslider.pack(side=BOTTOM, fill=X, expand=1)
        self.timeslider_last_update = time.time()
        ctrlpanel2.pack(side=BOTTOM, fill=X)

        # VLC player controls
        self.Instance = vlc.Instance()
        self.player = self.Instance.media_player_new()
        self.timer = ttkTimer(self.OnTimer, 1.0)
        self.timer.start()
        self.parent.update()
Пример #10
0
cwd = os.getcwd()

logging.basicConfig(filename=cwd + "\\Log.txt",
                    level=logging.DEBUG,
                    format='%(asctime)s %(message)s',
                    datefmt='%m/%d/%y %H:%M:%S')
############################################################################
########################### GUI Structure
############################################################################
tabFrame = Frame(main)
tabFrame.grid(row=0)

tabLocation = ttk.Notebook(tabFrame)
tabLocation.grid(row=0, column=0, columnspan=50, rowspan=49, sticky='NESW')

tab_deploy = ttk.Frame(tabLocation)
tabLocation.add(tab_deploy, text="FIO Menu")

tab_advanced = ttk.Frame(tabLocation)
tabLocation.add(tab_advanced, text="Advanced")


def frame_gui():
    titleLabel = main
    titleLabel.title("EasyFIO")


# tab1 variables
wim_location = StringVar()
check_desktopfiles = IntVar()
check_desktopfiles.set(1)
Пример #11
0
    def __init__(self, parent, callback):
        tk.Toplevel.__init__(self, parent)

        self.parent = parent
        self.callback = callback
        self.title(platform == 'darwin' and _('Preferences') or _('Settings'))

        if parent.winfo_viewable():
            self.transient(parent)

        # position over parent
        if platform != 'darwin' or parent.winfo_rooty(
        ) > 0:  # http://core.tcl.tk/tk/tktview/c84f660833546b1b84e7
            self.geometry("+%d+%d" %
                          (parent.winfo_rootx(), parent.winfo_rooty()))

        # remove decoration
        if platform == 'win32':
            self.attributes('-toolwindow', tk.TRUE)
        elif platform == 'darwin':
            # http://wiki.tcl.tk/13428
            parent.call('tk::unsupported::MacWindowStyle', 'style', self,
                        'utility')
        self.resizable(tk.FALSE, tk.FALSE)

        self.cmdr = False  # Note if Cmdr changes in the Journal

        frame = ttk.Frame(self)
        frame.grid(sticky=tk.NSEW)

        notebook = nb.Notebook(frame)
        notebook.bind('<<NotebookTabChanged>>',
                      self.outvarchanged)  # Recompute on tab change

        PADX = 10
        BUTTONX = 12  # indent Checkbuttons and Radiobuttons
        PADY = 2  # close spacing

        credframe = nb.Frame(notebook)
        credframe.columnconfigure(1, weight=1)

        nb.Label(credframe, text=_('Credentials')).grid(
            padx=PADX, sticky=tk.W)  # Section heading in settings
        ttk.Separator(credframe, orient=tk.HORIZONTAL).grid(columnspan=2,
                                                            padx=PADX,
                                                            pady=PADY,
                                                            sticky=tk.EW)
        self.cred_label = nb.Label(
            credframe,
            text=_('Please log in with your Elite: Dangerous account details'
                   ))  # Use same text as E:D Launcher's login dialog
        self.cred_label.grid(padx=PADX, columnspan=2, sticky=tk.W)
        self.cmdr_label = nb.Label(credframe, text=_('Cmdr'))  # Main window
        self.cmdr_label.grid(row=10, padx=PADX, sticky=tk.W)
        self.username_label = nb.Label(
            credframe, text=_('Username (Email)')
        )  # Use same text as E:D Launcher's login dialog
        self.username_label.grid(row=11, padx=PADX, sticky=tk.W)
        self.password_label = nb.Label(
            credframe,
            text=_('Password'))  # Use same text as E:D Launcher's login dialog
        self.password_label.grid(row=12, padx=PADX, sticky=tk.W)

        self.cmdr_text = nb.Label(credframe)
        self.cmdr_text.grid(row=10,
                            column=1,
                            padx=PADX,
                            pady=PADY,
                            sticky=tk.W)
        self.username = nb.Entry(credframe)
        self.username.grid(row=11,
                           column=1,
                           padx=PADX,
                           pady=PADY,
                           sticky=tk.EW)
        if not monitor.is_beta and monitor.cmdr:
            self.username.focus_set()
        self.password = nb.Entry(credframe, show=u'•')
        self.password.grid(row=12,
                           column=1,
                           padx=PADX,
                           pady=PADY,
                           sticky=tk.EW)

        nb.Label(credframe).grid(sticky=tk.W)  # big spacer
        nb.Label(credframe, text=_('Privacy')).grid(
            padx=PADX, sticky=tk.W)  # Section heading in settings
        ttk.Separator(credframe, orient=tk.HORIZONTAL).grid(columnspan=2,
                                                            padx=PADX,
                                                            pady=PADY,
                                                            sticky=tk.EW)

        self.out_anon = tk.IntVar(value=config.getint('anonymous') and 1)
        nb.Label(
            credframe,
            text=_('How do you want to be identified in the saved data')).grid(
                columnspan=2, padx=PADX, sticky=tk.W)
        nb.Radiobutton(credframe,
                       text=_('Cmdr name'),
                       variable=self.out_anon,
                       value=0).grid(columnspan=2, padx=BUTTONX,
                                     sticky=tk.W)  # Privacy setting
        nb.Radiobutton(credframe,
                       text=_('Pseudo-anonymized ID'),
                       variable=self.out_anon,
                       value=1).grid(columnspan=2, padx=BUTTONX,
                                     sticky=tk.W)  # Privacy setting

        notebook.add(credframe, text=_('Identity'))  # Tab heading in settings

        outframe = nb.Frame(notebook)
        outframe.columnconfigure(0, weight=1)

        output = config.getint('output') or (
            config.OUT_MKT_EDDN | config.OUT_SYS_EDDN | config.OUT_SHIP
        )  # default settings

        self.out_label = nb.Label(outframe,
                                  text=_('Please choose what data to save'))
        self.out_label.grid(columnspan=2, padx=PADX, sticky=tk.W)
        self.out_csv = tk.IntVar(value=(output & config.OUT_MKT_CSV) and 1)
        self.out_csv_button = nb.Checkbutton(
            outframe,
            text=_('Market data in CSV format file'),
            variable=self.out_csv,
            command=self.outvarchanged)
        self.out_csv_button.grid(columnspan=2, padx=BUTTONX, sticky=tk.W)
        self.out_td = tk.IntVar(value=(output & config.OUT_MKT_TD) and 1)
        self.out_td_button = nb.Checkbutton(
            outframe,
            text=_('Market data in Trade Dangerous format file'),
            variable=self.out_td,
            command=self.outvarchanged)
        self.out_td_button.grid(columnspan=2, padx=BUTTONX, sticky=tk.W)
        self.out_ship = tk.IntVar(
            value=(output & (config.OUT_SHIP | config.OUT_SHIP_EDS
                             | config.OUT_SHIP_CORIOLIS) and 1))
        self.out_ship_button = nb.Checkbutton(
            outframe,
            text=_('Ship loadout'),
            variable=self.out_ship,
            command=self.outvarchanged)  # Output setting
        self.out_ship_button.grid(columnspan=2,
                                  padx=BUTTONX,
                                  pady=(5, 0),
                                  sticky=tk.W)
        self.out_auto = tk.IntVar(value=0 if output
                                  & config.OUT_MKT_MANUAL else 1)  # inverted
        self.out_auto_button = nb.Checkbutton(
            outframe,
            text=_('Automatically update on docking'),
            variable=self.out_auto,
            command=self.outvarchanged)  # Output setting
        self.out_auto_button.grid(columnspan=2,
                                  padx=BUTTONX,
                                  pady=(5, 0),
                                  sticky=tk.W)

        self.outdir = tk.StringVar()
        self.outdir.set(config.get('outdir'))
        self.outdir_label = nb.Label(outframe, text=_('File location') +
                                     ':')  # Section heading in settings
        self.outdir_label.grid(padx=BUTTONX, pady=(5, 0), sticky=tk.W)
        self.outdir_entry = nb.Entry(outframe, takefocus=False)
        self.outdir_entry.grid(row=20, padx=(PADX, 0), sticky=tk.EW)
        self.outbutton = nb.Button(
            outframe,
            text=(
                platform == 'darwin' and _('Change...')
                or  # Folder selection button on OSX
                _('Browse...')),  # Folder selection button on Windows
            command=lambda: self.filebrowse(_('File location'), self.outdir))
        self.outbutton.grid(row=20, column=1, padx=PADX, sticky=tk.NSEW)
        nb.Frame(outframe).grid(pady=5)  # bottom spacer

        notebook.add(outframe, text=_('Output'))  # Tab heading in settings

        eddnframe = nb.Frame(notebook)

        HyperlinkLabel(eddnframe,
                       text='Elite Dangerous Data Network',
                       background=nb.Label().cget('background'),
                       url='https://github.com/jamesremuscat/EDDN/wiki',
                       underline=True).grid(padx=PADX,
                                            sticky=tk.W)  # Don't translate
        self.eddn_station = tk.IntVar(
            value=(output & config.OUT_MKT_EDDN) and 1)
        self.eddn_station_button = nb.Checkbutton(
            eddnframe,
            text=_('Send station data to the Elite Dangerous Data Network'),
            variable=self.eddn_station,
            command=self.outvarchanged)  # Output setting
        self.eddn_station_button.grid(padx=BUTTONX, pady=(5, 0), sticky=tk.W)
        self.eddn_auto_button = nb.Checkbutton(
            eddnframe,
            text=_('Automatically update on docking'),
            variable=self.out_auto,
            command=self.outvarchanged)  # Output setting
        self.eddn_auto_button.grid(padx=BUTTONX, sticky=tk.W)
        self.eddn_system = tk.IntVar(
            value=(output & config.OUT_SYS_EDDN) and 1)
        self.eddn_system_button = nb.Checkbutton(
            eddnframe,
            text=_(
                'Send system and scan data to the Elite Dangerous Data Network'
            ),
            variable=self.eddn_system,
            command=self.outvarchanged)  # Output setting new in E:D 2.2
        self.eddn_system_button.grid(padx=BUTTONX, pady=(5, 0), sticky=tk.W)
        self.eddn_delay = tk.IntVar(
            value=(output & config.OUT_SYS_DELAY) and 1)
        self.eddn_delay_button = nb.Checkbutton(
            eddnframe,
            text=_('Delay sending until docked'),
            variable=self.eddn_delay
        )  # Output setting under 'Send system and scan data to the Elite Dangerous Data Network' new in E:D 2.2
        self.eddn_delay_button.grid(padx=BUTTONX, sticky=tk.W)

        notebook.add(eddnframe, text='EDDN')  # Not translated

        edsmframe = nb.Frame(notebook)
        edsmframe.columnconfigure(1, weight=1)

        HyperlinkLabel(edsmframe,
                       text='Elite Dangerous Star Map',
                       background=nb.Label().cget('background'),
                       url='https://www.edsm.net/',
                       underline=True).grid(columnspan=2,
                                            padx=PADX,
                                            sticky=tk.W)  # Don't translate
        self.edsm_log = tk.IntVar(value=(output & config.OUT_SYS_EDSM) and 1)
        self.edsm_log_button = nb.Checkbutton(
            edsmframe,
            text=_('Send flight log to Elite Dangerous Star Map'),
            variable=self.edsm_log,
            command=self.outvarchanged)
        self.edsm_log_button.grid(columnspan=2,
                                  padx=BUTTONX,
                                  pady=(5, 0),
                                  sticky=tk.W)

        nb.Label(edsmframe).grid(sticky=tk.W)  # big spacer
        self.edsm_label = HyperlinkLabel(
            edsmframe,
            text=_('Elite Dangerous Star Map credentials'),
            background=nb.Label().cget('background'),
            url='https://www.edsm.net/settings/api',
            underline=True)  # Section heading in settings
        self.edsm_label.grid(columnspan=2, padx=PADX, sticky=tk.W)

        self.edsm_cmdr_label = nb.Label(edsmframe,
                                        text=_('Cmdr'))  # Main window
        self.edsm_cmdr_label.grid(row=10, padx=PADX, sticky=tk.W)
        self.edsm_cmdr_text = nb.Label(edsmframe)
        self.edsm_cmdr_text.grid(row=10,
                                 column=1,
                                 padx=PADX,
                                 pady=PADY,
                                 sticky=tk.W)

        self.edsm_user_label = nb.Label(
            edsmframe, text=_('Commander Name'))  # EDSM setting
        self.edsm_user_label.grid(row=11, padx=PADX, sticky=tk.W)
        self.edsm_user = nb.Entry(edsmframe)
        self.edsm_user.grid(row=11,
                            column=1,
                            padx=PADX,
                            pady=PADY,
                            sticky=tk.EW)

        self.edsm_apikey_label = nb.Label(edsmframe,
                                          text=_('API Key'))  # EDSM setting
        self.edsm_apikey_label.grid(row=12, padx=PADX, sticky=tk.W)
        self.edsm_apikey = nb.Entry(edsmframe)
        self.edsm_apikey.grid(row=12,
                              column=1,
                              padx=PADX,
                              pady=PADY,
                              sticky=tk.EW)

        notebook.add(edsmframe, text='EDSM')  # Not translated

        # build plugin prefs tabs
        for plugname in plug.PLUGINS:
            plugframe = plug.get_plugin_prefs(plugname, notebook)
            if plugframe:
                notebook.add(plugframe, text=plugname)

        configframe = nb.Frame(notebook)
        configframe.columnconfigure(1, weight=1)

        self.logdir = tk.StringVar()
        self.logdir.set(
            config.get('journaldir') or config.default_journal_dir or '')
        self.logdir_entry = nb.Entry(configframe, takefocus=False)

        if platform != 'darwin':
            # Apple's SMB implementation is way too flaky - no filesystem events and bogus NULLs
            nb.Label(
                configframe, text=_('E:D journal file location') + ':').grid(
                    columnspan=3, padx=PADX,
                    sticky=tk.W)  # Location of the new Journal file in E:D 2.2
            self.logdir_entry.grid(row=10,
                                   columnspan=2,
                                   padx=(PADX, 0),
                                   sticky=tk.EW)
            self.logbutton = nb.Button(
                configframe,
                text=(
                    platform == 'darwin' and _('Change...')
                    or  # Folder selection button on OSX
                    _('Browse...')),  # Folder selection button on Windows
                command=lambda: self.filebrowse(_('E:D journal file location'),
                                                self.logdir))
            self.logbutton.grid(row=10, column=2, padx=PADX, sticky=tk.EW)
            if config.default_journal_dir:
                nb.Button(
                    configframe,
                    text=_('Default'),
                    command=self.logdir_reset,
                    state=config.get('journaldir') and tk.NORMAL
                    or tk.DISABLED).grid(
                        column=2, padx=PADX, pady=(5, 0),
                        sticky=tk.EW)  # Appearance theme and language setting

        if platform == 'win32':
            ttk.Separator(configframe,
                          orient=tk.HORIZONTAL).grid(columnspan=3,
                                                     padx=PADX,
                                                     pady=PADY * 8,
                                                     sticky=tk.EW)

        if platform in ['darwin', 'win32']:
            self.hotkey_code = config.getint('hotkey_code')
            self.hotkey_mods = config.getint('hotkey_mods')
            self.hotkey_only = tk.IntVar(
                value=not config.getint('hotkey_always'))
            self.hotkey_play = tk.IntVar(
                value=not config.getint('hotkey_mute'))
            nb.Label(
                configframe,
                text=platform == 'darwin' and _('Keyboard shortcut')
                or  # Hotkey/Shortcut settings prompt on OSX
                _('Hotkey')  # Hotkey/Shortcut settings prompt on Windows
            ).grid(row=20, padx=PADX, sticky=tk.W)
            if platform == 'darwin' and not was_accessible_at_launch:
                if AXIsProcessTrusted():
                    nb.Label(
                        configframe,
                        text=_('Re-start {APP} to use shortcuts').format(
                            APP=applongname),
                        foreground='firebrick').grid(
                            padx=PADX,
                            sticky=tk.W)  # Shortcut settings prompt on OSX
                else:
                    nb.Label(
                        configframe,
                        text=_('{APP} needs permission to use shortcuts'
                               ).format(APP=applongname),
                        foreground='firebrick').grid(
                            columnspan=3, padx=PADX,
                            sticky=tk.W)  # Shortcut settings prompt on OSX
                    nb.Button(
                        configframe,
                        text=_('Open System Preferences'),
                        command=self.enableshortcuts).grid(
                            column=2, padx=PADX,
                            sticky=tk.E)  # Shortcut settings button on OSX
            else:
                self.hotkey_text = nb.Entry(configframe,
                                            width=(platform == 'darwin' and 20
                                                   or 30),
                                            justify=tk.CENTER)
                self.hotkey_text.insert(
                    0, self.hotkey_code
                    and hotkeymgr.display(self.hotkey_code, self.hotkey_mods)
                    or _('None'))  # No hotkey/shortcut currently defined
                self.hotkey_text.bind('<FocusIn>', self.hotkeystart)
                self.hotkey_text.bind('<FocusOut>', self.hotkeyend)
                self.hotkey_text.grid(row=20,
                                      column=1,
                                      columnspan=2,
                                      padx=PADX,
                                      pady=(5, 0),
                                      sticky=tk.W)
                self.hotkey_only_btn = nb.Checkbutton(
                    configframe,
                    text=_('Only when Elite: Dangerous is the active app'),
                    variable=self.hotkey_only,
                    state=self.hotkey_code and tk.NORMAL
                    or tk.DISABLED)  # Hotkey/Shortcut setting
                self.hotkey_only_btn.grid(columnspan=3,
                                          padx=PADX,
                                          pady=(5, 0),
                                          sticky=tk.W)
                self.hotkey_play_btn = nb.Checkbutton(
                    configframe,
                    text=_('Play sound'),
                    variable=self.hotkey_play,
                    state=self.hotkey_code and tk.NORMAL
                    or tk.DISABLED)  # Hotkey/Shortcut setting
                self.hotkey_play_btn.grid(columnspan=3, padx=PADX, sticky=tk.W)

        ttk.Separator(configframe, orient=tk.HORIZONTAL).grid(columnspan=3,
                                                              padx=PADX,
                                                              pady=PADY * 8,
                                                              sticky=tk.EW)
        nb.Label(configframe, text=_('Preferred Shipyard')).grid(
            columnspan=3, padx=PADX, sticky=tk.W
        )  # Setting to decide which ship outfitting website to link to - either E:D Shipyard or Coriolis.
        self.shipyard = tk.IntVar(value=config.getint('shipyard'))
        nb.Radiobutton(configframe,
                       text='E:D Shipyard',
                       variable=self.shipyard,
                       value=config.SHIPYARD_EDSHIPYARD).grid(columnspan=3,
                                                              padx=BUTTONX,
                                                              pady=(5, 0),
                                                              sticky=tk.W)
        nb.Radiobutton(configframe,
                       text='Coriolis',
                       variable=self.shipyard,
                       value=config.SHIPYARD_CORIOLIS).grid(columnspan=3,
                                                            padx=BUTTONX,
                                                            sticky=tk.W)
        nb.Label(configframe).grid(sticky=tk.W)  # big spacer

        notebook.add(configframe,
                     text=_('Configuration'))  # Tab heading in settings

        self.languages = Translations().available_names()
        self.lang = tk.StringVar(value=self.languages.get(
            config.get('language'),
            _('Default')))  # Appearance theme and language setting
        self.always_ontop = tk.BooleanVar(value=config.getint('always_ontop'))
        self.theme = tk.IntVar(value=config.getint('theme'))
        self.theme_colors = [
            config.get('dark_text'),
            config.get('dark_highlight')
        ]
        self.theme_prompts = [
            _('Normal text'),  # Dark theme color setting
            _('Highlighted text'),  # Dark theme color setting
        ]
        themeframe = nb.Frame(notebook)
        themeframe.columnconfigure(2, weight=1)
        nb.Label(themeframe, text=_('Language')).grid(
            row=10, padx=PADX, sticky=tk.W)  # Appearance setting prompt
        self.lang_button = nb.OptionMenu(themeframe, self.lang,
                                         self.lang.get(),
                                         *self.languages.values())
        self.lang_button.grid(row=10,
                              column=1,
                              columnspan=2,
                              padx=PADX,
                              sticky=tk.W)
        ttk.Separator(themeframe, orient=tk.HORIZONTAL).grid(columnspan=3,
                                                             padx=PADX,
                                                             pady=PADY * 8,
                                                             sticky=tk.EW)
        nb.Label(themeframe,
                 text=_('Theme')).grid(columnspan=3, padx=PADX,
                                       sticky=tk.W)  # Appearance setting
        nb.Radiobutton(
            themeframe,
            text=_('Default'),
            variable=self.theme,
            value=0,
            command=self.themevarchanged).grid(
                columnspan=3, padx=BUTTONX,
                sticky=tk.W)  # Appearance theme and language setting
        nb.Radiobutton(themeframe,
                       text=_('Dark'),
                       variable=self.theme,
                       value=1,
                       command=self.themevarchanged).grid(
                           columnspan=3, padx=BUTTONX,
                           sticky=tk.W)  # Appearance theme setting
        if platform == 'win32':
            nb.Radiobutton(themeframe,
                           text=_('Transparent'),
                           variable=self.theme,
                           value=2,
                           command=self.themevarchanged).grid(
                               columnspan=3, padx=BUTTONX,
                               sticky=tk.W)  # Appearance theme setting
        self.theme_label_0 = nb.Label(themeframe, text=self.theme_prompts[0])
        self.theme_label_0.grid(row=20, padx=PADX, sticky=tk.W)
        self.theme_button_0 = nb.ColoredButton(
            themeframe,
            text=_('Station'),
            background='grey4',
            command=lambda: self.themecolorbrowse(0))  # Main window
        self.theme_button_0.grid(row=20,
                                 column=1,
                                 padx=PADX,
                                 pady=PADY,
                                 sticky=tk.NSEW)
        self.theme_label_1 = nb.Label(themeframe, text=self.theme_prompts[1])
        self.theme_label_1.grid(row=21, padx=PADX, sticky=tk.W)
        self.theme_button_1 = nb.ColoredButton(
            themeframe,
            text='  Hutton Orbital  ',
            background='grey4',
            command=lambda: self.themecolorbrowse(1))  # Do not translate
        self.theme_button_1.grid(row=21,
                                 column=1,
                                 padx=PADX,
                                 pady=PADY,
                                 sticky=tk.NSEW)
        ttk.Separator(themeframe, orient=tk.HORIZONTAL).grid(columnspan=3,
                                                             padx=PADX,
                                                             pady=PADY * 8,
                                                             sticky=tk.EW)
        self.ontop_button = nb.Checkbutton(themeframe,
                                           text=_('Always on top'),
                                           variable=self.always_ontop,
                                           command=self.themevarchanged)
        self.ontop_button.grid(columnspan=3, padx=BUTTONX,
                               sticky=tk.W)  # Appearance setting
        nb.Label(themeframe).grid(sticky=tk.W)  # big spacer

        notebook.add(themeframe,
                     text=_('Appearance'))  # Tab heading in settings

        if platform == 'darwin':
            self.protocol("WM_DELETE_WINDOW",
                          self.apply)  # close button applies changes
        else:
            buttonframe = ttk.Frame(frame)
            buttonframe.grid(padx=PADX, pady=PADX, sticky=tk.NSEW)
            buttonframe.columnconfigure(0, weight=1)
            ttk.Label(buttonframe).grid(row=0, column=0)  # spacer
            button = ttk.Button(buttonframe, text=_('OK'), command=self.apply)
            button.grid(row=0, column=1, sticky=tk.E)
            button.bind("<Return>", lambda event: self.apply())
            self.protocol("WM_DELETE_WINDOW", self._destroy)

        # Selectively disable buttons depending on output settings
        self.outvarchanged()
        self.themevarchanged()

        # disable hotkey for the duration
        hotkeymgr.unregister()

        # wait for window to appear on screen before calling grab_set
        self.parent.wm_attributes(
            '-topmost',
            0)  # needed for dialog to appear ontop of parent on OSX & Linux
        self.wait_visibility()
        self.grab_set()

        # Ensure fully on-screen
        if platform == 'win32':
            position = RECT()
            if CalculatePopupWindowPosition(
                    POINT(parent.winfo_rootx(), parent.winfo_rooty()),
                    SIZE(self.winfo_width(), self.winfo_height()), 0x10000,
                    None, position):
                self.geometry("+%d+%d" % (position.left, position.top))
Пример #12
0
    def __init__(self, parent_top):
        self.decode_top = Toplevel(parent_top)
        self.decode_top.title("Decoder")
        self.decode_top.geometry('800x600+300+220')
        self.decode_top.iconbitmap(icon_path)
        self.decode_top.attributes("-toolwindow", 1)
        #self.decode_top.wm_attributes('-topmost',1)

        n = ttk.Notebook(self.decode_top)
        f1 = ttk.Frame(
            n,
            height=500)  # first page, which would get widgets gridded into it
        f2 = ttk.Frame(n)  # second page
        n.add(f1, text='One')
        n.add(f2, text='Two')
        lab1 = Label(f1, text='Parse BSC real time message trace',\
         font = ('Helvetica', 12, 'bold'), fg='blue')
        lab1.pack()

        #option###################
        p_option = ttk.Panedwindow(f1, orient=VERTICAL)
        lf_option = ttk.Labelframe(p_option,
                                   text='Option',
                                   width=620,
                                   height=120)
        p_option.add(lf_option)

        self.vversion = StringVar()
        self.v_select = ttk.Combobox(lf_option,
                                     textvariable=self.vversion,
                                     width=30)
        self.v_select['values'] = ('LR14.3', 'LR13.3', 'LR11')
        self.v_select['state'] = "readonly"
        self.v_select.current(0)
        self.v_select.bind("<<ComboboxSelected>>", self.select_version)
        v_label = Label(lf_option, text='Select Version').grid(row=0, column=1)
        self.v_select.grid(row=0, column=2)
        n_label = Label(lf_option, text='*').grid(row=0, column=3)

        m_label = Label(lf_option, text='Buffer Mode').grid(row=1, column=1)
        m_entry = Entry(lf_option, width=33).grid(row=1, column=2)

        blank_label1 = Label(lf_option, text=' ' * 10).grid(row=0, column=4)
        blank_label2 = Label(lf_option, text=' ' * 10).grid(row=1, column=4)

        o_label = Label(lf_option, text='Object Name').grid(row=0, column=5)
        o_entry = Entry(lf_option, width=33).grid(row=0, column=6)

        f_label = Label(lf_option, text='Field Mode').grid(row=1, column=5)
        f_entry = Entry(lf_option, width=33).grid(row=1, column=6)

        p_option.pack(expand=YES, fill=BOTH)
        #option###################

        blank_label = Label(f1, text='')
        blank_label.pack()

        #raw content################
        p_raw = ttk.Panedwindow(f1, orient=VERTICAL)
        lf_raw = ttk.Labelframe(p_raw,
                                text='Message Content(Raw Trace)',
                                width=620,
                                height=320)
        p_raw.add(lf_raw)

        self.text_pad = Text(lf_raw, undo=True, width=600, height=300)
        self.text_pad.pack(expand=YES, fill=BOTH)
        scroll = Scrollbar(self.text_pad)
        self.text_pad.config(yscrollcommand=scroll.set)
        scroll.config(command=self.text_pad.yview)
        scroll.pack(side=RIGHT, fill=Y)
        self.text_pad.insert(1.0, "这里粘贴日志信息")
        p_raw.pack(expand=YES, fill=BOTH)

        #raw content################

        #button###################
        self.button_frm = Frame(f1)
        self.decode_button = Button(self.button_frm,
                                    text="decode",
                                    background=my_color_green,
                                    command=self.log_translate)
        self.decode_button.pack(side=LEFT)
        self.reset_button = Button(self.button_frm,
                                   text="reset",
                                   command=self.reset_translate)
        self.reset_button.pack()
        self.button_frm.pack()
        #button###################

        #Resut###################
        p = ttk.Panedwindow(f1, orient=VERTICAL)
        fp1 = ttk.Labelframe(p, text='Result', width=620, height=220)
        p.add(fp1)
        self.result_pad = Text(fp1, undo=True, width=600, height=200)
        self.result_pad.pack(expand=YES, fill=BOTH)
        p.pack(expand=YES, fill=BOTH)
        #Resut###################

        #notepad2#################
        lab2 = Label(f2, text='graphic')
        lab2.pack()
        self.can = Canvas(f2, width=600, height=600, bg='#00FFFF')
        self.can.create_line((0, 0), (200, 200), width=5)
        self.can.create_text(300, 30, text="Scenario Figure")
        self.can.pack()
        #notepad2#################

        n.pack()
Пример #13
0
    def __init__(self, text1, score1, text2, score2, textarea, top=None):
        '''This class configures and populates the toplevel window.
           top is the toplevel containing window.'''
        _bgcolor = '#d9d9d9'  # X11 color: 'gray85'
        _fgcolor = '#000000'  # X11 color: 'black'
        _compcolor = '#d9d9d9'  # X11 color: 'gray85'
        _ana1color = '#d9d9d9'  # X11 color: 'gray85'
        _ana2color = '#ececec'  # Closest X11 color: 'gray92'
        font11 = "-family {Segoe UI} -size 14 -weight normal -slant " \
                 "roman -underline 0 -overstrike 0"
        font9 = "-family {Segoe UI} -size 14 -weight bold -slant roman" \
                " -underline 0 -overstrike 0"
        self.style = ttk.Style()
        if sys.platform == "win32":
            self.style.theme_use('winnative')
        self.style.configure('.', background=_bgcolor)
        self.style.configure('.', foreground=_fgcolor)
        self.style.configure('.', font="TkDefaultFont")
        self.style.map('.',
                       background=[('selected', _compcolor),
                                   ('active', _ana2color)])

        top.geometry("569x393+481+142")
        top.title("New Toplevel")
        top.configure(background="#d5d8c7")

        self.TFrameback = ttk.Frame(top)
        self.TFrameback.place(relx=0.018,
                              rely=0.025,
                              relheight=0.929,
                              relwidth=0.958)
        self.TFrameback.configure(relief='sunken')
        self.TFrameback.configure(borderwidth="2")
        self.TFrameback.configure(relief='sunken')
        self.TFrameback.configure(width=545)

        self.TLabelsuggest = ttk.Label(self.TFrameback)
        self.TLabelsuggest.place(relx=0.514, rely=0.0, height=29, width=175)
        self.TLabelsuggest.configure(background="#F0F0F0")
        self.TLabelsuggest.configure(foreground="#000000")
        self.TLabelsuggest.configure(font=font9)
        self.TLabelsuggest.configure(relief='flat')
        self.TLabelsuggest.configure(text='''Degre de similarite:''')

        self.TLabeLPourcent1 = ttk.Label(self.TFrameback)
        self.TLabeLPourcent1.place(relx=0.862, rely=0.0, height=25, width=58)
        self.TLabeLPourcent1.configure(background="#F0F0F0")
        self.TLabeLPourcent1.configure(foreground="#ef1818")
        self.TLabeLPourcent1.configure(font=font11)
        self.TLabeLPourcent1.configure(relief='flat')
        self.TLabeLPourcent1.configure(text=score1)
        self.TLabeLPourcent1.configure(width=58)

        self.TFrame2 = ttk.Frame(self.TFrameback)
        self.TFrame2.place(relx=0.018,
                           rely=0.11,
                           relheight=0.342,
                           relwidth=0.963)
        self.TFrame2.configure(relief='groove')
        self.TFrame2.configure(borderwidth="2")
        self.TFrame2.configure(relief='groove')
        self.TFrame2.configure(width=525)

        self.TLabel3 = ttk.Label(self.TFrame2)
        self.TLabel3.place(relx=0.019, rely=0.08, height=109, width=416)
        self.TLabel3.configure(background="#F0F0F0")
        self.TLabel3.configure(foreground="#000000")
        self.TLabel3.configure(font="TkDefaultFont")
        self.TLabel3.configure(relief='flat')
        self.TLabel3.configure(wraplength="400")
        self.TLabel3.configure(text=text1)
        self.TLabel3.configure(width=416)

        self.cop2 = tk.Button(
            self.TFrame2,
            command=lambda: copie_suggested_mail(text1, textarea))

        self.cop2.place(relx=0.819, rely=0.24, height=54, width=87)
        self.cop2.configure(activebackground="#EFCD49")
        self.cop2.configure(activeforeground="#000000")
        self.cop2.configure(background="#EFCD49")
        self.cop2.configure(disabledforeground="#a3a3a3")
        self.cop2.configure(foreground="#000000")
        self.cop2.configure(highlightbackground="#EFCD49")
        self.cop2.configure(highlightcolor="black")
        self.cop2.configure(pady="0")
        self.cop2.configure(relief='groove')
        self.cop2.configure(text='''Copier''')
        self.cop2.configure(width=87)

        self.TFrame2_2 = ttk.Frame(self.TFrameback)
        self.TFrame2_2.place(relx=0.018,
                             rely=0.603,
                             relheight=0.37,
                             relwidth=0.963)
        self.TFrame2_2.configure(relief='groove')
        self.TFrame2_2.configure(borderwidth="2")
        self.TFrame2_2.configure(relief='groove')
        self.TFrame2_2.configure(width=525)

        self.TLabel3_3 = ttk.Label(self.TFrame2_2)
        self.TLabel3_3.place(relx=0.019, rely=0.074, height=109, width=416)
        self.TLabel3_3.configure(background="#F0F0F0")
        self.TLabel3_3.configure(foreground="#000000")
        self.TLabel3_3.configure(font="TkDefaultFont")
        self.TLabel3_3.configure(relief='flat')
        self.TLabel3_3.configure(wraplength="400")
        self.TLabel3_3.configure(text=text2)

        self.TlabelPourc2 = ttk.Label(self.TFrameback)
        self.TlabelPourc2.place(relx=0.862, rely=0.493, height=25, width=58)
        self.TlabelPourc2.configure(background="#F0F0F0")
        self.TlabelPourc2.configure(foreground="#ef1818")
        self.TlabelPourc2.configure(font=font11)
        self.TlabelPourc2.configure(relief='flat')
        self.TlabelPourc2.configure(text=score2)

        self.TLabelsuggest_6 = ttk.Label(self.TFrameback)
        self.TLabelsuggest_6.place(relx=0.514,
                                   rely=0.493,
                                   height=29,
                                   width=175)
        self.TLabelsuggest_6.configure(background="#F0F0F0")
        self.TLabelsuggest_6.configure(foreground="#000000")
        self.TLabelsuggest_6.configure(font=font9)
        self.TLabelsuggest_6.configure(relief='flat')
        self.TLabelsuggest_6.configure(text='''Degre de similarite:''')
        self.TLabelsuggest_6.configure(width=175)

        self.TLabelsuggest_7 = ttk.Label(self.TFrameback)
        self.TLabelsuggest_7.place(relx=0.018,
                                   rely=0.027,
                                   height=29,
                                   width=175)
        self.TLabelsuggest_7.configure(background="#F0F0F0")
        self.TLabelsuggest_7.configure(foreground="#556080")
        self.TLabelsuggest_7.configure(font=font9)
        self.TLabelsuggest_7.configure(relief='flat')
        self.TLabelsuggest_7.configure(text='''Suggestion 1:''')

        self.TLabelsuggest_8 = ttk.Label(self.TFrameback)
        self.TLabelsuggest_8.place(relx=0.018,
                                   rely=0.493,
                                   height=29,
                                   width=195)
        self.TLabelsuggest_8.configure(background="#F0F0F0")
        self.TLabelsuggest_8.configure(foreground="#556080")
        self.TLabelsuggest_8.configure(font=font9)
        self.TLabelsuggest_8.configure(relief='flat')
        self.TLabelsuggest_8.configure(text='''Suggestion 2:''')
        self.TLabelsuggest_8.configure(width=195)

        self.btncop2 = tk.Button(
            self.TFrameback,
            command=lambda: copie_suggested_mail(text2, textarea))
        self.btncop2.place(relx=0.807, rely=0.712, height=54, width=87)
        self.btncop2.configure(activebackground="#EFCD49")
        self.btncop2.configure(activeforeground="#000000")
        self.btncop2.configure(background="#EFCD49")
        self.btncop2.configure(disabledforeground="#a3a3a3")
        self.btncop2.configure(foreground="#000000")
        self.btncop2.configure(highlightbackground="#EFCD49")
        self.btncop2.configure(highlightcolor="black")
        self.btncop2.configure(pady="0")
        self.btncop2.configure(relief='groove')
        self.btncop2.configure(text='''Copier''')
Пример #14
0
def main():
    def variables_scrollbar_limits_set(event):
        variables_canvas.configure(scrollregion=variables_canvas.bbox("all"), width=variables_frame.winfo_width(), height=variables_frame.winfo_height())

    def plot_scrollbar_limits_set(event):
        plot_canvas.configure(scrollregion=plot_canvas.bbox("all"), width=plot_frame.winfo_width(), height=180)

    def resize_variable_frame(event):
        variables_canvas.itemconfig(in_canvas_variable_frame_id, width=variables_canvas.winfo_width()-variable_scrollbar.winfo_width())

    def resize_plot_frame(event):
        plot_canvas.itemconfig(in_canvas_plot_frame_id, height=plot_canvas.winfo_height()-plot_scrollbar.winfo_height())

    def get_coordinates(event):
        global xpos
        xpos=event.x
        global ypos
        ypos=event.y

    def _on_mousewheel(event):
        if root.winfo_containing(xpos, ypos) != None: #TODO: improove scroll detection
            variables_canvas.yview_scroll(-1 * (event.delta / 120), "units")

    def add_variable(Variable_name='', Varible_value=''):
        def delete_variable():
            variable_name.destroy()
            variable_value.destroy()
            varialve_delete_butotn.destroy()
            variables.pop(variable_name)
        global r
        varialve_delete_butotn = ttk.Button(in_canvas_variables_frame, text='X', command=delete_variable)
        varialve_delete_butotn.grid(row=r)

        variable_name = ttk.Combobox(in_canvas_variables_frame, values=experiment.Ordered_supported_parameters.keys(),
                                     state="readonly")
        if Variable_name != '':
            variable_name.current(Variable_name)
        variable_name.grid(row=r, column=1)

        variable_value = ttk.Entry(in_canvas_variables_frame)
        variable_value.grid(row=r, column=2, sticky='E W')
        variable_value.insert(tk.END, Varible_value)

        variables[variable_name] = variable_value
        r+=1

    def check_plot_validity(box, other_boxes, *args):
        for other_box_variable in other_boxes:
            for list_variable in args:
                if other_box_variable.get() in list_variable:
                    box['values'] = list_variable.keys()
                    return True
        else:
            combined_list = [item for sublist in args for item in sublist.keys()]
            box['values'] = combined_list

    def add_plot(Plot_name=None, X_variable_name='', Y_variable_name=''):
        global c
        if Plot_name == None:
            Plot_name = 'Plot '+str(c+1)
        def delete_plot():
            specific_plot_frame.destroy()
            plots.pop(plot_name)
        specific_plot_frame = ttk.Frame(in_canvas_plot_frame, relief=tk.RIDGE)
        specific_plot_frame.grid(row=0, column=c, sticky='news')
        plot_name = ttk.Entry(specific_plot_frame)
        plot_name.insert(tk.END, Plot_name)
        plot_name.grid(row=0, column=0, columnspan=2, padx=10, pady=10)
        plot_lable = ttk.Label(specific_plot_frame, text='x:')
        plot_lable.grid(row=1, column=0, ipady=5, padx=10)
        x_variable_name = ttk.Combobox(specific_plot_frame, values=experiment.Ordered_supported_parameters.keys(),
                                       state="readonly", postcommand=lambda: check_plot_validity(x_variable_name, [y_variable_name], SUPPORTED_FIT_RESULTS, Ordered_supported_parameters))
        x_variable_name.grid(row=1, column=1, padx=10)
        plot_y_lable = ttk.Label(specific_plot_frame, text='y:')
        plot_y_lable.grid(row=2, column=0, pady=10)
        y_variable_name = ttk.Combobox(specific_plot_frame, values=experiment.Ordered_supported_parameters.keys(),
                                       state="readonly", postcommand=lambda: check_plot_validity(y_variable_name, [x_variable_name], SUPPORTED_FIT_RESULTS, Ordered_supported_parameters))
        y_variable_name.grid(row=2, column=1, pady=10)
        spacing = tk.Label(specific_plot_frame)
        spacing.grid(row=3)
        plot_delete_buttion = ttk.Button(specific_plot_frame, text='X', command=delete_plot)
        plot_delete_buttion.grid(row=4, column=0, columnspan=2, sticky='nsew')

        plots[plot_name] = (x_variable_name, y_variable_name)
        c+=1

    def add_3d_plot(Plot_name=None, X_variable_name='', Y_variable_name='', Z_variable_name=''):
        global c
        if Plot_name == None:
            Plot_name = '3d plot '+str(c+1)
        def delete_plot():
            specific_plot_frame.destroy()
            plots.pop(plot_name)
        specific_plot_frame = ttk.Frame(in_canvas_plot_frame, relief=tk.RIDGE)
        specific_plot_frame.grid(row=0, column=c, sticky='news')
        plot_name = ttk.Entry(specific_plot_frame)
        plot_name.insert(tk.END, Plot_name)
        plot_name.grid(row=0, column=0, columnspan=2, padx=10, pady=10)
        plot_lable = ttk.Label(specific_plot_frame, text='x:')
        plot_lable.grid(row=1, column=0, ipady=5, padx=10)
        x_variable_name = ttk.Combobox(specific_plot_frame, values=experiment.Ordered_supported_parameters.keys(),
                                       state="readonly", postcommand=lambda: check_plot_validity(x_variable_name, [y_variable_name, z_variable_name], SUPPORTED_FIT_RESULTS, Ordered_supported_parameters))
        x_variable_name.grid(row=1, column=1, padx=10)
        plot_y_lable = ttk.Label(specific_plot_frame, text='y:')
        plot_y_lable.grid(row=2, column=0, pady=10)
        y_variable_name = ttk.Combobox(specific_plot_frame, values=experiment.Ordered_supported_parameters.keys(),
                                       state="readonly", postcommand=lambda: check_plot_validity(y_variable_name, [x_variable_name, z_variable_name], SUPPORTED_FIT_RESULTS, Ordered_supported_parameters))
        y_variable_name.grid(row=2, column=1, pady=10)
        plot_z_lable = ttk.Label(specific_plot_frame, text='z:')
        plot_z_lable.grid(row=3, column=0)
        z_variable_name = ttk.Combobox(specific_plot_frame, values=experiment.Ordered_supported_parameters.keys(),
                                       state="readonly", postcommand=lambda: check_plot_validity(z_variable_name, [y_variable_name, x_variable_name], SUPPORTED_FIT_RESULTS, Ordered_supported_parameters))
        z_variable_name.grid(row=3, column=1)
        plot_delete_buttion = ttk.Button(specific_plot_frame, text='X', command=delete_plot)
        plot_delete_buttion.grid(row=4, column=0, columnspan=2, sticky='nsew')

        plots[plot_name] = (x_variable_name, y_variable_name, z_variable_name)
        c+=1

    def make():
        try:
            vars = []
            parameters={}
            for var in variables.keys():
                vars.append(var.get())
            if len(vars) != len(set(vars)):
                msgbox.showerror('Error', 'choosing the same parameter twice is not allowed\n'
                                          'plese delet one')
                return 1

            for plot in plots:
                for axis in plots[plot]:
                    if not axis.get() in vars+SUPPORTED_FIT_RESULTS.keys():
                        if axis.get() == '':
                            msgbox.showerror('Error', 'enpthy field not allowed in plot')
                            return 1
                        else:
                            msgbox.showerror('Error', 'parameter '+axis.get()+' was not set')
                            return 1


            for variable in  variables.keys():
                parameters[variable.get()]=eval(variables[variable].get())

            experiment1 = Experiment(**parameters)
            print 'initializing...'
            experiment1.initialize()
            print 'building...'
            tree_root = build_tree(experiment1.Tree)
            with open(tree_root+'\\parameters.json', 'w') as fo:
                json.dump(experiment1.parameters, fo)
            print 'build done!'
            count_limit = device.run(experiment1, tree_root, experiment1.parameters['freqency_list'], experiment1.parameters['powers_list'])
            print count_limit
            while True:
                if device.counter.value==count_limit:
                    break
            print '\ndone!'
            data = experiment.load_data('./tree')
            plot_list = []
            for plot in plots:
                if len(plots[plot]) == 3:
                    plot_list.append(([plots[plot][0].get(),plots[plot][1].get(),plots[plot][2].get()],))
                elif len(plots[plot]) == 2:
                    plot_list.append(([plots[plot][0].get(), plots[plot][1].get()],))
            # report_generator.make_report(data, plot_list)
            print 'a'

        except:
            msgbox.showerror('Error', 'plese check the following things:\n'
                                      '* all values are in brackets\n'
                                      '* all values are separated by commas\n'
                                      '* make shure that freqency_list and powers are set\n'
                                      'example:\n'
                                      '\t[1.25, 25, 1.235e+3, 1.74e-6]')


    root = tk.Tk()
    screen_width = root.winfo_screenwidth()
    screen_height = root.winfo_screenheight()
    x = screen_width / 2 - screen_width * 0.75 / 2
    y = screen_height / 2 - screen_height * 0.75 / 2
    root.geometry(str(int(screen_width*0.75))+'x'+str(int(screen_height*0.75)))
    root.geometry("+%d+%d" % (int(x), int(y)))

    buttons_frame = ttk.Frame(root)
    buttons_frame.grid(row=0, sticky='w')

    add_button = ttk.Button(buttons_frame, text='add', command=add_variable)
    add_button.grid(row=0, column=0, sticky='nsew')

    new_plot_buttom = ttk.Button(buttons_frame, text='new plot', command=add_plot)
    new_plot_buttom.grid(row=0, column=1, sticky='nsew')

    new_3d_plot_button = ttk.Button(buttons_frame, text='new 3d plot', command=add_3d_plot)
    new_3d_plot_button.grid(row=0, column=2, sticky='nsew')

    make = ttk.Button(buttons_frame, text='Make', command=make)
    make.grid(row=0, column=3, sticky='nsew')

    variables_frame = ttk.Frame(root, relief=tk.GROOVE)
    variables_frame.grid(row=1, sticky='nsew')
    variables_canvas = tk.Canvas(variables_frame)#, highlightthickness=0)
    in_canvas_variables_frame = tk.Frame(variables_canvas)
    variable_scrollbar = ttk.Scrollbar(variables_frame, orient=tk.VERTICAL, command=variables_canvas.yview)
    variables_canvas.configure(yscrollcommand=variable_scrollbar.set)
    variable_scrollbar.pack(side="right", fill="y")
    variables_canvas.pack(side="left", fill=tk.X, expand=True)
    in_canvas_variable_frame_id = variables_canvas.create_window((0, 0), window=in_canvas_variables_frame, anchor='nw')
    in_canvas_variables_frame.bind("<Configure>", variables_scrollbar_limits_set)
    variables_canvas.bind("<Configure>", resize_variable_frame)
    root.bind('<Motion>', get_coordinates)
    in_canvas_variables_frame.bind_all("<MouseWheel>", _on_mousewheel)

    plot_frame = ttk.Frame(root, relief=tk.GROOVE)
    plot_frame.grid(row=2, sticky='nsew')
    plot_canvas = tk.Canvas(plot_frame)
    in_canvas_plot_frame = tk.Frame(plot_canvas)
    plot_scrollbar = ttk.Scrollbar(plot_frame, orient=tk.HORIZONTAL, command=plot_canvas.xview)
    plot_canvas.configure(xscrollcommand=plot_scrollbar.set)
    plot_scrollbar.pack(side="bottom", fill=tk.X)
    plot_canvas.pack(side="top", fill=tk.X, expand=True)
    in_canvas_plot_frame_id = plot_canvas.create_window((0, 0), window=in_canvas_plot_frame, anchor='nw')
    in_canvas_plot_frame.bind("<Configure>", plot_scrollbar_limits_set)
    plot_canvas.bind("<Configure>", resize_plot_frame)
    root.bind('<Motion>', get_coordinates)
    root.bind_all("<MouseWheel>", _on_mousewheel)

    root.rowconfigure(0, weight=0)
    root.rowconfigure(1, weight=3)
    root.rowconfigure(2, weight=1)
    root.columnconfigure(0, weight=1)
    in_canvas_variables_frame.columnconfigure(0, weight=0)
    in_canvas_variables_frame.columnconfigure(1, weight=0)
    in_canvas_variables_frame.columnconfigure(2, weight=1)

    add_variable(0,'[5,6]')
    add_variable(1,'[2.2, 3.5, 6.7, 8]')
    add_plot()
    add_3d_plot()


    root.mainloop()
Пример #15
0
    def launch_client(self):
        self.host = self.host_entry.get()
        self.port = 15000
        self.nick = self.nick_entry.get()

        self.host_entry_label.destroy()
        self.host_entry.destroy()
        self.nick_entry_label.destroy()
        self.nick_entry.destroy()
        self.launch_button.destroy()
        self.frame.pack_forget()

        self.title('ChatUp Client: {0}'.format(self.nick))

        self.should_quit = False

        self.protocol('WM_DELETE_WINDOW', self.client_quit)

        self.chat_frame = ttk.Frame(self.frame, borderwidth=5)
        self.clients_frame = ttk.Frame(self.frame)
        self.entry_frame = ttk.Frame(self)

        self.chat_frame.style = ttk.Style()
        self.chat_frame.style.theme_use(self.theme_use)
        self.clients_frame.style = ttk.Style()
        self.clients_frame.style.theme_use(self.theme_use)
        self.entry_frame.style = ttk.Style()
        self.entry_frame.style.theme_use(self.theme_use)

        self.chat_text = tkinter.Text(self.chat_frame, state=tkinter.DISABLED)

        self.chat_entry = ttk.Entry(self.entry_frame)
        self.send_button = ttk.Button(self.entry_frame, text='Send')

        self.send_button.bind('<Button-1>', self.send)
        self.chat_entry.bind('<Return>', self.send)

        self.entry_frame.pack(side=tkinter.BOTTOM, fill=tkinter.X)
        self.frame.pack(side=tkinter.TOP, fill=tkinter.BOTH, expand=True)
        self.clients_frame.pack(side=tkinter.LEFT,
                                fill=tkinter.BOTH,
                                expand=True)
        self.chat_frame.pack(side=tkinter.RIGHT,
                             fill=tkinter.BOTH,
                             expand=True)

        self.chat_entry.pack(side=tkinter.LEFT, fill=tkinter.X, expand=True)
        self.send_button.pack(side=tkinter.RIGHT)

        self.client_socket = socket.socket(socket.AF_INET, socket.SOCK_STREAM)

        self.client_socket.connect((self.host, self.port))
        self.client_socket.send('Please allow connection!%&%{0}%&%'.format(
            self.nick))
        self.clients = ast.literal_eval(self.client_socket.recv(1024)[11:])

        self.dest = tkinter.StringVar()
        self.radios = []

        self.radio_label = ttk.Label(
            self.clients_frame,
            width=15,
            wraplength=125,
            anchor=tkinter.W,
            justify=tkinter.LEFT,
            text='Choose reciever from the following connected clients:')

        self.radio_label.pack()
        self.chat_text.pack(fill=tkinter.BOTH, expand=True)

        self.__i = 0
        self.__j = 1

        for client in self.clients:
            r = ttk.Radiobutton(self.clients_frame,
                                text=client,
                                variable=self.dest,
                                value=client)
            r.pack(anchor=tkinter.W)

            self.radios.append(r)

        self.dest.set(self.clients[0])

        self.chat_entry.focus_set()

        self.clientd_thread = threading.Thread(name='clientd',
                                               target=self.clientd)

        self.clientd_thread.start()
Пример #16
0
    def __init__(self):

        # Available models
        self.available_models = opendrift.get_model_names()

        tk.Tk.__init__(self)

        ##################
        # Layout frames
        ##################
        self.n = ttk.Notebook(self.master)
        self.n.grid()
        self.seed = ttk.Frame(self.n)
        self.config = ttk.Frame(self.n)
        self.n.add(self.seed, text='Seeding')
        self.n.add(self.config, text='Config')

        # Top
        self.top = tk.Frame(self.seed, relief=tk.FLAT, pady=25, padx=25)
        self.top.grid(row=0, column=1, rowspan=1)
        # Config
        self.con = tk.Label(self.config, text="\n\nConfiguration\n\n")
        self.con.grid(row=0, column=1, rowspan=1)
        # Time start and end
        self.start_t = tk.Frame(self.seed, relief=tk.FLAT)
        self.start_t.grid(row=2, column=0, rowspan=1)
        self.end_t = tk.Frame(self.seed, relief=tk.FLAT)
        self.end_t.grid(row=3, column=0, rowspan=1)
        self.start = tk.Frame(self.seed,
                              bg='lightgray',
                              bd=2,
                              relief=tk.SUNKEN,
                              pady=5,
                              padx=5)
        self.start.grid(row=2, column=1, rowspan=1)
        self.end = tk.Frame(self.seed,
                            bg='gray',
                            bd=2,
                            relief=tk.SUNKEN,
                            padx=5,
                            pady=5)
        self.end.grid(row=3, column=1)
        self.coastline = tk.Frame(self.seed,
                                  bd=2,
                                  relief=tk.FLAT,
                                  padx=5,
                                  pady=0)
        self.coastline.grid(row=4, column=1)
        self.duration = tk.Frame(self.seed,
                                 bd=2,
                                 relief=tk.FLAT,
                                 padx=5,
                                 pady=5)
        self.duration.grid(row=5, column=1)
        self.seed_frame = tk.Frame(self.seed,
                                   bd=2,
                                   relief=tk.FLAT,
                                   padx=5,
                                   pady=0)
        self.seed_frame.grid(row=4, columnspan=8, sticky='nsew')
        self.output = tk.Frame(self.seed, bd=2, relief=tk.FLAT, padx=5, pady=0)
        self.output.grid(row=7, column=2, columnspan=8, sticky='nsew')

        ##########################
        self.title('OpenDrift')
        o = OpenOil3D(weathering_model='noaa', location='NORWAY')
        try:
            img = ImageTk.PhotoImage(
                Image.open(o.test_data_folder() +
                           '../../docs/opendrift_logo.png'))
            panel = tk.Label(self.seed, image=img)
            panel.image = img
            panel.grid(row=0, column=0)
        except:
            pass  # Could not display logo
        #######################################################
        tk.Label(self.top, text='Simulation type').grid(row=0, column=0)
        self.model = tk.StringVar()
        models = ['OpenOil', 'Leeway']
        models = opendrift.get_model_names()
        self.model.set(models[0])
        self.modeldrop = tk.OptionMenu(self.top,
                                       self.model,
                                       *(models),
                                       command=self.set_model)
        self.modeldrop.grid(row=0, column=1)

        help_button = tk.Button(self.top, text='Help', command=self.show_help)
        help_button.grid(row=0, column=2, padx=50)

        self.categoryLabel = tk.Label(self.seed, text='Oil type')
        self.categoryLabel.grid(row=1, column=0)
        oljetyper = o.oiltypes
        self.oljetype = tk.StringVar()
        self.oljetype.set(oljetyper[0])
        self.categorydrop = ttk.Combobox(self.seed,
                                         width=50,
                                         textvariable=self.oljetype,
                                         values=oljetyper)
        self.categorydrop.grid(row=1, column=1)

        ##########
        # Release
        ##########
        startlabel = tk.Label(self.start_t, text="\n\nStart release\n\n")
        startlabel.grid(row=0, column=0)

        tk.Label(self.start, text='Longitude').grid(row=0, column=1)
        tk.Label(self.start, text='Latitude').grid(row=0, column=0)
        tk.Label(self.start, text='Radius [m]').grid(row=0, column=2)
        self.latvar = tk.StringVar()
        self.lonvar = tk.StringVar()
        self.radiusvar = tk.StringVar()
        self.lat = tk.Entry(self.start,
                            textvariable=self.latvar,
                            width=6,
                            justify=tk.RIGHT)
        self.lon = tk.Entry(self.start,
                            textvariable=self.lonvar,
                            width=6,
                            justify=tk.RIGHT)
        self.radius = tk.Entry(self.start,
                               width=6,
                               textvariable=self.radiusvar,
                               justify=tk.RIGHT)
        self.lon.grid(row=1, column=1)
        self.lon.insert(0, '4.5')
        self.lat.grid(row=1, column=0)
        self.lat.insert(0, '60.0')
        self.radius.grid(row=1, column=2)
        self.radius.insert(0, '1000')
        self.lonvar.trace('w', self.copy_position)
        self.latvar.trace('w', self.copy_position)
        self.radiusvar.trace('w', self.copy_position)
        ##########
        # Time
        ##########
        now = datetime.now()
        tk.Label(self.start, text='Day').grid(row=2, column=0)
        tk.Label(self.start, text='Month').grid(row=2, column=1)
        tk.Label(self.start, text='Year').grid(row=2, column=2)
        tk.Label(self.start, text='Hour').grid(row=2, column=3)
        tk.Label(self.start, text='Minutes [UTC]').grid(row=2, column=4)
        self.datevar = tk.StringVar()
        self.dates = range(1, 32)
        self.datevar.set(now.day)
        self.date = tk.OptionMenu(self.start, self.datevar, *self.dates)
        self.date.grid(row=3, column=0)

        self.monthvar = tk.StringVar()
        self.months = [
            'January', 'February', 'March', 'April', 'May', 'June', 'July',
            'August', 'September', 'October', 'November', 'December'
        ]
        self.monthvar.set(self.months[now.month - 1])
        self.month = tk.OptionMenu(self.start, self.monthvar, *self.months)
        self.month.grid(row=3, column=1)

        self.yearvar = tk.StringVar()
        self.years = range(2015, now.year + 1)
        self.yearvar.set(now.year)
        self.year = tk.OptionMenu(self.start, self.yearvar, *self.years)
        self.year.grid(row=3, column=2)

        self.hourvar = tk.StringVar()
        self.hours = range(0, 24)
        self.hourvar.set(now.hour)
        self.hour = tk.OptionMenu(self.start, self.hourvar, *self.hours)
        self.hour.grid(row=3, column=3)

        self.minutevar = tk.StringVar()
        self.minutes = range(0, 60, 5)
        self.minutevar.set(now.minute)
        self.minute = tk.OptionMenu(self.start, self.minutevar, *self.minutes)
        self.minute.grid(row=3, column=4)

        self.datevar.trace('w', self.copy_position)
        self.monthvar.trace('w', self.copy_position)
        self.yearvar.trace('w', self.copy_position)
        self.hourvar.trace('w', self.copy_position)
        self.minutevar.trace('w', self.copy_position)

        ###############
        # Release End
        ###############
        endlabel = tk.Label(self.end_t, text="\n\nEnd release\n\n")
        endlabel.grid(row=0, column=0)
        tk.Label(self.end, text='Longitude', bg='gray').grid(row=0, column=1)
        tk.Label(self.end, text='Latitude', bg='gray').grid(row=0, column=0)
        tk.Label(self.end, text='Radius [m]', bg='gray').grid(row=0, column=2)
        self.elat = tk.Entry(self.end, width=6, justify=tk.RIGHT)
        self.elon = tk.Entry(self.end, width=6, justify=tk.RIGHT)
        self.eradius = tk.Entry(self.end, width=6, justify=tk.RIGHT)
        self.elon.grid(row=1, column=1)
        self.elon.insert(0, '4.5')
        self.elat.grid(row=1, column=0)
        self.elat.insert(0, '60.0')
        self.eradius.grid(row=1, column=2)
        self.eradius.insert(0, '1000')
        ##########
        # Time
        ##########
        now = datetime.now()
        tk.Label(self.end, text='Day', bg='gray').grid(row=2, column=0)
        tk.Label(self.end, text='Month', bg='gray').grid(row=2, column=1)
        tk.Label(self.end, text='Year', bg='gray').grid(row=2, column=2)
        tk.Label(self.end, text='Hour', bg='gray').grid(row=2, column=3)
        tk.Label(self.end, text='Minutes [UTC]', bg='gray').grid(row=2,
                                                                 column=4)
        self.edatevar = tk.StringVar()
        self.edates = range(1, 32)
        self.edatevar.set(now.day)
        self.edate = tk.OptionMenu(self.end, self.edatevar, *self.edates)
        self.edate.grid(row=3, column=0)

        self.emonthvar = tk.StringVar()
        self.emonthvar.set(self.months[now.month - 1])
        self.emonth = tk.OptionMenu(self.end, self.emonthvar, *self.months)
        self.emonth.grid(row=3, column=1)

        self.eyearvar = tk.StringVar()
        self.eyears = range(2015, now.year + 1)
        self.eyearvar.set(now.year)
        self.eyear = tk.OptionMenu(self.end, self.eyearvar, *self.eyears)
        self.eyear.grid(row=3, column=2)

        self.ehourvar = tk.StringVar()
        self.ehours = range(0, 24)
        self.ehourvar.set(now.hour)
        self.ehour = tk.OptionMenu(self.end, self.ehourvar, *self.ehours)
        self.ehour.grid(row=3, column=3)

        self.eminutevar = tk.StringVar()
        self.eminutes = range(0, 60, 5)
        self.eminutevar.set(now.minute)
        self.eminute = tk.OptionMenu(self.end, self.eminutevar, *self.eminutes)
        self.eminute.grid(row=3, column=4)
        self.eyear.config(bg='gray')
        self.emonth.config(bg='gray')
        self.edate.config(bg='gray')
        self.ehour.config(bg='gray')
        self.eminute.config(bg='gray')

        # Check seeding
        check_seed = tk.Button(self.end_t,
                               text='Check seeding',
                               command=self.check_seeding)
        check_seed.grid(row=1, column=0, padx=0)

        #######################
        # Simulation duration
        #######################
        tk.Label(self.coastline, text='Coastline resolution ').grid(row=4,
                                                                    column=1)
        self.mapresvar = tk.StringVar()
        self.mapres = tk.OptionMenu(self.coastline, self.mapresvar,
                                    *['full', 'high'])
        self.mapres.grid(row=4, column=2)
        self.mapresvar.set('high')

        tk.Label(self.duration, text='Run simulation ').grid(row=5, column=0)
        self.durationhours = tk.Entry(self.duration, width=3, justify=tk.RIGHT)
        self.durationhours.grid(row=5, column=1)
        self.durationhours.insert(0, 12)
        tk.Label(self.duration, text=' hours ').grid(row=5, column=2)

        self.directionvar = tk.StringVar()
        self.directionvar.set('forwards')
        self.direction = tk.OptionMenu(self.duration, self.directionvar,
                                       'forwards', 'backwards')
        self.direction.grid(row=5, column=3)
        tk.Label(self.duration, text=' in time ').grid(row=5, column=4)

        ##############
        # Output box
        ##############
        self.text = tk.Text(self.output, wrap="word", height=18)
        self.text.grid(row=6, columnspan=8, sticky='nsew')
        self.text.tag_configure("stderr", foreground="#b22222")
        sys.stdout = TextRedirector(self.text, "stdout")
        sys.stderr = TextRedirector(self.text, "stderr")
        s = tk.Scrollbar(self)
        s.grid(row=6, column=8, sticky='ns')
        s.config(command=self.text.yview)
        self.text.config(yscrollcommand=s.set)

        # Diana
        self.dianadir = '/vol/vvfelles/opendrift/output/'
        if os.path.exists(self.dianadir):
            self.has_diana = True
            print 'Diana is available!'
            self.outputdir = '/vol/vvfelles/opendrift/output_native/'
        else:
            self.has_diana = False

        ##############
        # Initialise
        ##############
        o = OpenOil3D()

        for m in self.available_models:
            print m
            print opendrift.get_model(m)
            print opendrift.get_model(m)()

        ##########
        # RUN
        ##########
        tk.Button(self.seed,
                  text='PEIS PAO',
                  bg='green',
                  command=self.run_opendrift).grid(row=8,
                                                   column=1,
                                                   sticky=tk.W,
                                                   pady=4)
Пример #17
0
    def __init__(self, parent, data):
        tk.Toplevel.__init__(self, parent)

        self.parent = parent

        stats = status(data)
        self.title(' '.join(stats[0]))	# assumes first thing is player name

        if parent.winfo_viewable():
            self.transient(parent)

        # position over parent
        if platform!='darwin' or parent.winfo_rooty()>0:	# http://core.tcl.tk/tk/tktview/c84f660833546b1b84e7
            self.geometry("+%d+%d" % (parent.winfo_rootx(), parent.winfo_rooty()))

        # remove decoration
        self.resizable(tk.FALSE, tk.FALSE)
        if platform=='win32':
            self.attributes('-toolwindow', tk.TRUE)
        elif platform=='darwin':
            # http://wiki.tcl.tk/13428
            parent.call('tk::unsupported::MacWindowStyle', 'style', self, 'utility')

        frame = ttk.Frame(self)
        frame.grid(sticky=tk.NSEW)

        notebook = nb.Notebook(frame)

        page = self.addpage(notebook)
        for thing in stats[1:3]:
            self.addpagerow(page, [thing[0], self.credits(int(thing[1]))])	# assumes things two and three are money
        for thing in stats[3:]:
            self.addpagerow(page, thing)
        ttk.Frame(page).grid(pady=5)			# bottom spacer
        notebook.add(page, text=_('Status'))		# Status dialog title

        page = self.addpage(notebook, [
            _('Ship'),		# Status dialog subtitle
            '',
            _('System'),	# Main window
            _('Station'),	# Status dialog subtitle
            _('Value'),		# Status dialog subtitle - CR value of ship
        ])
        shiplist = ships(data)
        for thing in shiplist:
            self.addpagerow(page, list(thing[1:-1]) + [self.credits(int(thing[-1]))])	# skip id, last item is money
        ttk.Frame(page).grid(pady=5)			# bottom spacer
        notebook.add(page, text=_('Ships'))		# Status dialog title

        if platform!='darwin':
            buttonframe = ttk.Frame(frame)
            buttonframe.grid(padx=10, pady=(0,10), sticky=tk.NSEW)
            buttonframe.columnconfigure(0, weight=1)
            ttk.Label(buttonframe).grid(row=0, column=0)	# spacer
            ttk.Button(buttonframe, text='OK', command=self.destroy).grid(row=0, column=1, sticky=tk.E)

        # wait for window to appear on screen before calling grab_set
        self.wait_visibility()
        self.grab_set()

        # Ensure fully on-screen
        if platform == 'win32':
            position = RECT()
            GetWindowRect(GetParent(self.winfo_id()), position)
            if CalculatePopupWindowPosition(POINT(parent.winfo_rootx(), parent.winfo_rooty()),
                                            SIZE(position.right - position.left, position.bottom - position.top),
                                            0x10000, None, position):
                self.geometry("+%d+%d" % (position.left, position.top))
Пример #18
0
    def __init__(self, controller, parent):
        self.controller = controller
        
        self.bgStyle = ttk.Style()
        self.bgStyle.configure('White.TFrame', background="white")

        self.skillPage  = ttk.Frame(parent, relief=tk.RIDGE, padding=10)
        self.skillPage.grid(row=0, column=0, sticky= "NSEW")
        self.skillPage.grid_columnconfigure(0, weight=1, uniform="x")
        self.skillPage.grid_columnconfigure(1, weight=1, uniform="x")
        self.skillPage.grid_columnconfigure(2, weight=1, uniform="x")
        self.skillPage.grid_rowconfigure(0, weight=1, uniform="x")
        self.skillPage.grid_rowconfigure(1, weight=1, uniform="x")
        self.skillPage.grid_rowconfigure(2, weight=1, uniform="x")
        self.skillPage.grid_rowconfigure(3, weight=1, uniform="x")
        self.skillPage.grid_rowconfigure(4, weight=1, uniform="x")
        self.skillPage.grid_rowconfigure(5, weight=1, uniform="x")

        self.skillDict = self.controller.char.skill.skills
        
        #
        # Skill Frame
        #
        skills = []
        for skill in self.skillDict.keys():
            if self.skillDict[skill].list in ["Skill", "Knowledge"]:
                skills.append(skill)
        
        skills.sort()

        self.skillFrame = ttk.Frame(self.skillPage, relief=tk.SUNKEN, padding=10, style="White.TFrame")
        tk.Label(self.skillFrame, text="SKILL", bg="white").grid(row=0, column=0, columnspan=5, sticky="EW")
        ttk.Separator(self.skillFrame).grid(row=1, column=0, columnspan=5, sticky="EW", pady=5)
        self.populateFrame(self.skillFrame, skills)
        self.skillFrame.grid(row=0, column=0, sticky="NSEW", rowspan=6)

        #
        # Perform Frame
        #
        self.performFrame = ttk.Frame(self.skillPage, relief=tk.SUNKEN, padding=10, style="White.TFrame")
        self.performFrame.grid_rowconfigure(4, weight=1)
        self.performFrame.grid_propagate(0)

        tk.Label(self.performFrame, text="PERFORM", bg="white").grid(row=0,column=0, columnspan=5, sticky="EW")
        ttk.Separator(self.performFrame).grid(row=1, column=0, columnspan=5, sticky="EW", pady=5)
        innerFrame = self.populateFrame(self.performFrame)
        ttk.Separator(self.performFrame).grid(row=4, column=0, columnspan=5, sticky="SEW", pady=5)
        tk.Button(self.performFrame, text="Add", command= lambda i=innerFrame: self.controller.createSkillWindow("Perform", i)).grid(row=5, column=0, columnspan=5, sticky="SEW")

        self.performFrame.grid(row=0, column=1, sticky="NSEW", rowspan=2)

        #
        # Craft Frame
        #
        self.craftFrame = ttk.Frame(self.skillPage, relief=tk.SUNKEN, padding=10, style="White.TFrame")
        self.craftFrame.grid_rowconfigure(4, weight=1)

        tk.Label(self.craftFrame, text="CRAFT", bg="white").grid(row=0,column=0, columnspan=5, sticky="EW")
        ttk.Separator(self.craftFrame).grid(row=1, column=0, columnspan=5, sticky="EW", pady=5)
        innerFrame = self.populateFrame(self.craftFrame)
        ttk.Separator(self.craftFrame).grid(row=4, column=0, columnspan=5, sticky="SEW", pady=5)
        tk.Button(self.craftFrame, text="Add", command= lambda i=innerFrame: self.controller.createSkillWindow("Craft", i)).grid(row=5, column=0, columnspan=5, sticky="SEW")

        self.craftFrame.grid(row=2, column=1, sticky="NSEW", rowspan=2)

        #
        # Profession Frame
        #
        self.professionFrame = ttk.Frame(self.skillPage, relief=tk.SUNKEN, padding=10, style="White.TFrame")
        self.professionFrame.grid_rowconfigure(4, weight=1)

        tk.Label(self.professionFrame, text="PROFESSION", bg="white").grid(row=0,column=0, columnspan=5, sticky="EW")
        ttk.Separator(self.professionFrame).grid(row=1, column=0, columnspan=5, sticky="EW", pady=5)
        innerFrame = self.populateFrame(self.professionFrame)
        ttk.Separator(self.professionFrame).grid(row=4, column=0, columnspan=5, sticky="SEW", pady=5)
        tk.Button(self.professionFrame, text="Add", command= lambda i=innerFrame: self.controller.createSkillWindow("Profession", i)).grid(row=5, column=0, columnspan=5, sticky="SEW")

        self.professionFrame.grid(row=4, column=1, sticky="NSEW", rowspan=2)

        #
        # Summary Frame
        #
        self.summaryFrame = ttk.Frame(self.skillPage, relief=tk.SUNKEN, padding=10, style="White.TFrame")
        self.summaryFrame.grid(row=0, column=2, sticky="NSEW", rowspan=5)
        self.summaryFrame.grid_columnconfigure(0, weight=1)

        allSkills = self.skillDict.keys()
        allSkills.sort()

        self.skillFramesDict = {}

        i = 0
        for skillName in allSkills:
            skill = self.skillDict[skillName]

            frame = ttk.Frame(self.summaryFrame, style="White.TFrame")
            frame.grid_columnconfigure(0, weight=2, uniform="x")
            frame.grid_columnconfigure(1, weight=1, uniform="x")
            frame.grid_columnconfigure(2, weight=1, uniform="x")
            frame.grid_columnconfigure(3, weight=1, uniform="x")
            frame.grid_columnconfigure(4, weight=1, uniform="x")
            frame.grid_columnconfigure(5, weight=1, uniform="x")

            tk.Label(frame, text=skillName, font=("helvetica", 10), bg="white", anchor="w").grid(row=0, column=0, sticky="EW")
            tk.Label(frame, text=skill.statName, font=("helvetica", 10), bg="white").grid(row=0, column=1, sticky="EW")
            tk.Label(frame, textvariable=skill.value, font=("helvetica", 10), bg="white").grid(row=0, column=2, sticky="EW")
            tk.Label(frame, textvariable=skill.bonus, font=("helvetica", 10), bg="white").grid(row=0, column=3, sticky="EW")
            tk.Label(frame, textvariable=skill.rank, font=("helvetica", 10), bg="white").grid(row=0, column=4, sticky="EW")
            tk.Label(frame, textvariable=skill.modValue, font=("helvetica", 10), bg="white").grid(row=0, column=5, sticky="EW")

            frame.grid(row=i, column=0, sticky="EW")
            self.skillFramesDict[skill] = frame

            skill.value.trace("w", lambda i,o,x: self.updateSkillSummary())
            skill.show.trace("w", lambda i,o,x: self.updateSkillSummary())
            i += 1

        self.updateSkillSummary()

        
        #
        # Skill Points Frame
        #
        self.skillPoints = ttk.Frame(self.skillPage, relief=tk.SUNKEN, padding=10, style="White.TFrame")
        self.skillPoints.grid(row=5, column=2, sticky ="NSEW")
        self.skillPoints.grid_columnconfigure(0, weight=1)
        self.skillPoints.grid_columnconfigure(1, weight=1)
        self.skillPoints.grid_rowconfigure(0, weight=1)

        tk.Label(self.skillPoints, text="Skill Points: ", font=("helvetica", 16), bg="white").grid(row=0, column=0, sticky="NSE")
        tk.Label(self.skillPoints, textvariable=self.controller.char.skillPoints.value, font=("helvetica", 16), bg="white").grid(row=0, column=1,sticky="NSW")

        self.skillPage.update_idletasks()
Пример #19
0
    def __init__(self, root, resource_dir, log_level="INFO"):
        """
        create the main window.
        """

        ttk.Frame.__init__(self, root)

        self.resource_dir = resource_dir
        self.log_level = log_level

        gui_logger.setLevel(self.log_level)

        self.current_files = None
        self.current_output = os.path.join(sem.SEM_DATA_DIR, "outputs")
        if not os.path.exists(self.current_output):
            os.makedirs(self.current_output)

        self.master_zone = ttk.Frame(root)
        self.master_zone.grid(row=0,
                              column=0,
                              rowspan=2,
                              columnspan=1,
                              sticky="ns")
        self.master_zone.pack(side=tkinter.LEFT,
                              fill=tkinter.BOTH,
                              expand=True)

        self.file_select_zone = ttk.Frame(root)
        self.file_select_zone.pack(side=tkinter.LEFT,
                                   fill=tkinter.BOTH,
                                   expand=True)

        self.launch_zone = ttk.Frame(root)
        self.launch_zone.pack(side=tkinter.LEFT,
                              fill=tkinter.BOTH,
                              expand=True)

        self.lang_selector = SemTkLangSelector(self.master_zone,
                                               self.resource_dir)
        self.master = SemTkMasterSelector(self.master_zone, self.resource_dir)
        self.lang_selector.master_selector = self.master
        self.lang_selector.pack()
        self.master.pack()

        self.file_selector = SemTkFileSelector(self.file_select_zone,
                                               self,
                                               button_opt={
                                                   'fill': "both",
                                                   'padx': 5,
                                                   'pady': 5
                                               })
        self.file_selector.pack()
        root.bind("<Control-o>", self.file_selector.filenames)

        self.export_format_selector = SemTkExportSelector(self.launch_zone)
        self.export_format_selector.pack()

        self.launch_button = ttk.Button(self.launch_zone,
                                        text=u"launch SEM",
                                        command=self.launch_tagger)
        self.launch_button.pack(expand=True)
        self.haw = tkinter.PhotoImage(
            file=os.path.join(self.resource_dir, "images", "haw_24_24.gif"))
        self.launch_button.config(image=self.haw, compound=tkinter.LEFT)

        self.train_button = ttk.Button(self.launch_zone,
                                       text=u"train SEM",
                                       command=self.train_tagger)
        self.train_button.pack(expand=True)
        self.university = tkinter.PhotoImage(file=os.path.join(
            self.resource_dir, "images", "fa_university_24_24.gif"))
        self.train_button.config(image=self.university, compound=tkinter.LEFT)
Пример #20
0
window = tk.Tk()
window.title("HOME AUTOMATION SYSTEM")
window.geometry("440x410")

framec = tk.Frame(window)
framec.pack(fill="both")
ttk.Label(framec, text="").pack()
tk.Label(framec,
         text="HOME AUTOMATION SYSTEM",
         padx=10,
         pady=10,
         font=('Times', '12', 'bold')).pack()
ttk.Label(framec, text="").pack()

nb1 = ttk.Notebook(framec, padding=10)
framea = ttk.Frame(nb1)
nb1.add(framea, text="HEATER")
nb1.pack(expand=1, fill="both")
ttk.Label(framea, text="").pack()
ttk.Label(framea, text="").pack()

frame1 = tk.LabelFrame(framea,
                       cursor="top_left_corner",
                       text="Choose an option",
                       padx=20,
                       pady=20,
                       bd=5)
frame1.pack(fill="y")
ttk.Label(framea, text="").pack()
ttk.Label(framea, text="").pack()
Пример #21
0
    foo_thread = threading.Thread(target=foo)
    foo_thread.daemon = True
    progressbar.start()
    foo_thread.start()
    root.after(20, check_foo_thread)


def check_foo_thread():
    if foo_thread.is_alive():
        root.after(20, check_foo_thread)
    else:
        progressbar.stop()


root = Tk()
mainframe = ttk.Frame(root, padding="3 3 12 12")
mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)
progressbar = ttk.Progressbar(mainframe, mode='indeterminate')
progressbar.grid(column=1, row=100, sticky=W)

ttk.Button(mainframe, text="Check",
           command=lambda: start_foo_thread(None)).grid(column=1,
                                                        row=200,
                                                        sticky=E)

for child in mainframe.winfo_children():
    child.grid_configure(padx=5, pady=5)
root.bind('<Return>', start_foo_thread)
Пример #22
0
    def __init__(self, args):
        self.root = tk.Tk()
        self.root.protocol("WM_DELETE_WINDOW", self.on_closing)
        self.root.title("Manual Projection Rasterization")
        mainframe = ttk.Frame(self.root, padding="3 3 12 12")
        self.mainframe = mainframe
        mainframe.grid(column=0, row=0, sticky=(tk.N, tk.W, tk.E, tk.S))

        self.width = tk.IntVar()
        self.width.set(args.width)
        self.dpi = tk.IntVar()
        self.dpi.set(args.dpi)

        if args.cgfile:
            filename, = args.cgfile
        else:
            filename = askopenfilename(parent=mainframe,
                                       title='Please choose a *.cg file.',
                                       filetypes=[("cg files", ("*.cg",
                                                                "*.coord")),
                                                  ("All", "*")])
        self.cg = ftmc.CoarseGrainRNA(filename)
        #Image Display
        self.imgDisplay = ttk.Label(mainframe)
        mainframe.columnconfigure(0,
                                  minsize=min(int(args.width * 3.75 + 1), 100))
        mainframe.columnconfigure(1,
                                  minsize=min(int(args.width * 3.75 + 1), 100))
        mainframe.columnconfigure(2,
                                  minsize=min(int(args.width * 3.75 + 1), 100))
        mainframe.columnconfigure(3,
                                  minsize=min(int(args.width * 3.75 + 1), 100))
        mainframe.rowconfigure(6, minsize=min(int(args.width * 15 + 2), 400))
        self.imgDisplay.grid(row=6, column=0, columnspan=4, sticky="N")

        #Zoom Selection
        self.zoom = tk.IntVar()
        self.zoom.set(10)
        #self.zoom.set(10)
        ttk.Label(mainframe, text="Zoom:").grid(row=0, column=0, sticky="E")
        tk.Scale(mainframe,
                 from_=1,
                 to_=15,
                 orient=tk.HORIZONTAL,
                 command=self.update,
                 variable=self.zoom,
                 length=180).grid(row=0, column=1, sticky="W")
        #Nucleotide selection
        self.nucleotidePosition = tk.IntVar()
        self.nucleotidePosition.set(1)
        ttk.Label(mainframe, text="Nucleotide:").grid(row=1,
                                                      column=0,
                                                      sticky="E")
        tk.Scale(mainframe,
                 from_=1,
                 to_=len(self.cg.seq),
                 orient=tk.HORIZONTAL,
                 command=self.update,
                 length=len(self.cg.seq),
                 tickinterval=100,
                 variable=self.nucleotidePosition).grid(row=1,
                                                        column=1,
                                                        columnspan=3,
                                                        sticky="W")
        #Show virtual residues and stems
        self.showVres = tk.IntVar()
        self.showStems = tk.IntVar()
        ttk.Checkbutton(mainframe,
                        text="Show virtual residues",
                        command=self.update,
                        variable=self.showVres).grid(row=0, column=2)
        ttk.Checkbutton(mainframe,
                        text="Show stems",
                        command=self.update,
                        variable=self.showStems).grid(row=0, column=3)
        # Offset
        self.offset_x = tk.IntVar()
        self.offset_y = tk.IntVar()
        ttk.Label(mainframe, text="offset x (Angstrom):").grid(row=2,
                                                               column=0,
                                                               sticky="E")
        tk.Scale(mainframe,
                 from_=-100,
                 to_=100,
                 orient=tk.HORIZONTAL,
                 command=self.update,
                 variable=self.offset_x,
                 length=180).grid(row=2, column=1, sticky="W")
        ttk.Label(mainframe, text="offset y (Angstrom):").grid(row=3,
                                                               column=0,
                                                               sticky="E")
        tk.Scale(mainframe,
                 from_=-100,
                 to_=100,
                 orient=tk.HORIZONTAL,
                 command=self.update,
                 variable=self.offset_y,
                 length=180).grid(row=3, column=1, sticky="W")
        # Rotation
        self.inplane_rot = tk.IntVar()
        ttk.Label(mainframe, text="rotate (degrees)").grid(row=2,
                                                           column=2,
                                                           sticky="E")
        tk.Scale(mainframe,
                 from_=-180,
                 to_=180,
                 orient=tk.HORIZONTAL,
                 command=self.update,
                 variable=self.inplane_rot,
                 length=180).grid(row=2, column=3, sticky="W")
        #Projection Angles
        self.theta = tk.IntVar()
        self.phi = tk.IntVar()
        if self.cg.project_from is not None:
            r, t, p = ftuv.spherical_cartesian_to_polar(self.cg.project_from)
            self.theta.set(int(t))
            self.phi.set(int(p))
        ttk.Label(mainframe, text="Projection angle: THETA").grid(row=4,
                                                                  column=0,
                                                                  sticky="E")
        tk.Scale(mainframe,
                 from_=-180,
                 to_=180,
                 orient=tk.HORIZONTAL,
                 command=self.updateProjection,
                 variable=self.theta,
                 length=180).grid(row=4, column=1, sticky="W")
        ttk.Label(mainframe, text="Projection angle: PHI").grid(row=4,
                                                                column=2,
                                                                sticky="E")
        tk.Scale(mainframe,
                 from_=-90,
                 to_=90,
                 orient=tk.HORIZONTAL,
                 command=self.updateProjection,
                 variable=self.phi,
                 length=180).grid(row=4, column=3, sticky="W")
        # Action Buttons
        ttk.Button(mainframe,
                   text="Print Coordinates",
                   command=self.createLandmark).grid(row=3, column=2)
        ttk.Button(mainframe, text="Save Image as...",
                   command=self.saveImage).grid(row=3, column=3)

        # Select width and dpi
        ttk.Label(mainframe, text="Image width in Angstrom").grid(row=5,
                                                                  column=0,
                                                                  sticky="E")
        tk.Scale(mainframe,
                 from_=50,
                 to_=1000,
                 orient=tk.HORIZONTAL,
                 command=self.update,
                 variable=self.width,
                 length=180).grid(row=5, column=1, sticky="W")
        ttk.Label(mainframe, text="Image width in Pixels").grid(row=5,
                                                                column=2,
                                                                sticky="E")
        tk.Scale(mainframe,
                 from_=5,
                 to_=80,
                 orient=tk.HORIZONTAL,
                 command=self.update,
                 variable=self.dpi,
                 length=180).grid(row=5, column=3, sticky="W")

        self.proj = None
        self.updateProjection()
Пример #23
0
# print row
# c.writerow(row)
# print "Finished!"

#def insert_query():
# """ """

# def pipeline_query():
# """ """

# root is the activity window
root = Tk()
root.geometry("600x600")
root.title("MOlGEN NGS VARIANTS")
""" Visualisation frame for any searches"""
queryframe = ttk.Frame(root, width=100, height=100, padding="10 10 10 10")
queryframe.grid(column=1, row=2)
#queryframe.pack()
#sb1 = Scrollbar(queryframe, orient=VERTICAL)
#sb2 = Scrollbar(queryframe, orient=HORIZONTAL)
#tb = Text(queryframe, width=95, height=75, yscrollcommand=sb1.set, xscrollcommand=sb2.set )
#sb1.config(command=tb.yview)
#sb2.config(command=tb.xview)
#tb.grid(column= 2, row=3)
# tb.pack(side=LEFT, fill=BOTH, expand=1)
# sb1.pack(side=RIGHT, fill=Y)

queryframe.columnconfigure(0, weight=1)
queryframe.rowconfigure(0, weight=1)

variant = StringVar()
Пример #24
0
#!/usr/bin/env python
#coding:utf-8
# version:python2.7.15
# windows 10
# reference: python gui cookbook
import Tkinter as tk
import ttk
import tkMessageBox as mBox
from Tkinter import Menu

# 创建主窗口
win = tk.Tk()
win.title("Python gui")

tabControl = ttk.Notebook(win)  # Create Tab Control
tab1 = ttk.Frame(tabControl)  # Create a tab
tabControl.add(tab1, text='Tab 1')  # Add the tab
tab2 = ttk.Frame(tabControl)  # Add a second tab
tabControl.add(tab2, text='Tab 2')  # Make second tab visible
tab3 = ttk.Frame(tabControl)  # Add a third tab
tabControl.add(tab3, text='Tab 3')  # Make second tab visible
tabControl.pack(expand=1, fill="both")  # Pack to make visible

tab3 = tk.Frame(tab3, bg='blue')
tab3.pack()
for orangeColor in range(2):
    canvas = tk.Canvas(tab3,
                       width=150,
                       height=80,
                       highlightthickness=0,
                       bg='orange')
Пример #25
0
                strip_data = data.strip()
                info = strip_data.split(',',5)
                tree.insert('', i,values=(info[0], info[1], info[2], info[3], info[4],info[5]))
                i += 1
#关闭子窗口
def close_child_window():
    child_window.withdraw()
    tree.delete(*tree.get_children())
#---------------------------------------------------------------------
top = Tk()
child_window = Toplevel(top)
child_window.withdraw()
#设置gui标题
top.title('标贯击数的校正')
#添加框架
mainframe = ttk.Frame(top,padding='3 3 12 12')
childframe = ttk.Frame(child_window,padding='3 3 12 12')
#添加grid
mainframe.grid(column=0,row=0,sticky=(N,W,E,S))
childframe.grid(column=0,row=0,sticky=(N,W,E,S))
#添加label,位置以column/row确定
ttk.Label(mainframe,text='标贯击数的校正',font=20).grid(column=1,row=1,sticky=(W,E))
ttk.Label(mainframe,text='N\':').grid(column=0,row=2,sticky=W)
ttk.Label(mainframe,text='触探杆长度:').grid(column=0,row=3,sticky=W)
ttk.Label(mainframe,text='e0:').grid(column=0,row=7,sticky=W)
ttk.Label(mainframe,text='N:').grid(column=0,row=9,sticky=W)

#添加输入框,输入值设定为待处理的N值
N = StringVar()
n_entry = ttk.Entry(mainframe,width=20,textvariable=N)
n_entry.grid(column=1,row=2)
Пример #26
0
for i in matches:
	print i.keys()
	print '\n', i['title'], i['year'], i['kind'], '\n'

'''


def clear():
    pass


ui = Tk()

ui.title("Actor Matcher")

mainframe = ttk.Frame(ui, padding="5 5 5 5", borderwidth=20, relief='sunken')
mainframe.grid(column=0, row=1, sticky=(N, S, E, W))
mainframe.columnconfigure(0, weight=1)
mainframe.rowconfigure(0, weight=1)

act_a = StringVar()
act_b = StringVar()

actor_a_ent = ttk.Entry(mainframe, width=20, textvariable=act_a)
actor_a_ent.grid(column=2, row=1, sticky=W)

actor_b_ent = ttk.Entry(mainframe, width=20, textvariable=act_b)
actor_b_ent.grid(column=2, row=2, sticky=W)

ttk.Label(mainframe, text='Actor A').grid(column=1, row=1, sticky=W)
ttk.Label(mainframe, text='Actor B').grid(column=1, row=2, sticky=W)
Пример #27
0
    def create_GUI(self):
        default_font = tkFont.nametofont("TkDefaultFont")
        default_font.configure(size=12)
        self.option_add("*Font", default_font)

        self.master.title("Spotify Player")

        global mainframe
        mainframe = ttk.Frame(self, padding="3 3 12 12")
        mainframe.grid(column=0, row=0, sticky=(N, W, E, S))
        mainframe.columnconfigure(0, weight=1)
        mainframe.rowconfigure(0, weight=1)

        search_frame = ttk.Frame(mainframe, padding="3 3 12 0")
        search_frame.grid(column=0, row=0, sticky=(N, W, E, S))
        search_frame.columnconfigure(0, weight=1)
        search_frame.rowconfigure(0, weight=1)

        search_entry_frame = ttk.Frame(search_frame, padding="3 3 12 0")
        search_entry_frame.grid(column=0, row=0, sticky=(N, W, E, S))
        search_entry_frame.columnconfigure(0, weight=1)
        search_entry_frame.rowconfigure(0, weight=1)

        search_button_frame = ttk.Frame(search_frame, padding="3 3 12 0")
        search_button_frame.grid(column=0, row=1, sticky=(N, W, E, S))
        search_button_frame.columnconfigure(0, weight=1)
        search_button_frame.rowconfigure(0, weight=1)

        global results_frame
        results_frame = ttk.Frame(mainframe, padding="3 3 12 0")

        ######################################################################################
        ####
        #### Track and Artist Search Entries
        ####
        #### Search Button
        ####
        ######################################################################################

        track_search_name = StringVar(None, "")
        artist_search_name = StringVar(None, "")

        track_search_label = ttk.Label(search_entry_frame, text="Track Name")
        track_search_label.grid(column=0, row=0)

        track_search_entry = ttk.Entry(search_entry_frame,
                                       width=20,
                                       textvariable=track_search_name)
        track_search_entry.grid(column=1, row=0)

        artist_search_label = ttk.Label(search_entry_frame, text="Artist Name")
        artist_search_label.grid(column=0, row=1)

        artist_search_entry = ttk.Entry(search_entry_frame,
                                        width=20,
                                        textvariable=artist_search_name)
        artist_search_entry.grid(column=1, row=1)

        search_button = tk.Button(
            search_button_frame,
            text="Search",
            background="DarkSeaGreen1",
            command=lambda: self.search_and_display_results(
                track_search_name.get(), artist_search_name.get()))
        search_button.grid(column=0, row=0, sticky=(N, W, E, S))

        # Pad all frames within the mainframe
        for child in search_entry_frame.winfo_children():
            child.grid_configure(padx=5, pady=5)
        for child in search_button_frame.winfo_children():
            child.grid_configure(padx=5, pady=5)

        self.mainloop()
    def novo(self):

        self.style.configure('TNotebook.Tab', background=self._bgcolor)
        self.style.configure('TNotebook.Tab', foreground=self._fgcolor)
        self.style.map('TNotebook.Tab', background=[('selected', self._compcolor), ('active',self._ana2color)])
        self.nb = ttk.Notebook(self.top)
        self.nb.place(relx=0.0, rely=0.0, relheight=1.01, relwidth=1.0)
        self.nb.configure(width=824)
        self.nb.configure(takefocus="")
        self.fr_topologia = ttk.Frame(self.nb)
        self.nb.add(self.fr_topologia, padding=3)
        self.nb.tab(0, text="Topologia",underline="-1",)
        self.fr_configuracoes = ttk.Frame(self.nb)
        self.nb.add(self.fr_configuracoes, padding=3)
        self.nb.tab(1, text="Configurações",underline="-1",)
        self.fr_saida = ttk.Frame(self.nb)
        self.nb.add(self.fr_saida, padding=3)
        self.nb.tab(2, text="Saída",underline="-1",)
        self.fr_simular = ttk.Frame(self.nb)
        self.nb.add(self.fr_simular, padding=3)
        self.nb.tab(3, text="Simular",underline="-1",)

        """
        ABA TOPOLOGIA
        """
        self.btn_no = ttk.Button(self.fr_topologia)
        self.btn_no.place(relx=0.01, rely=0.02, height=25, width=106)
        self.btn_no.configure(takefocus="")
        self.btn_no.configure(text='''Nó''')
        self.btn_no.configure(width=106)

        self.btn_aresta = ttk.Button(self.fr_topologia)
        self.btn_aresta.place(relx=0.17, rely=0.02, height=25, width=106)
        self.btn_aresta.configure(takefocus="")
        self.btn_aresta.configure(text='''Aresta''')
        self.btn_aresta.configure(width=106)

        self.desenho_topologia = Canvas(self.fr_topologia)
        self.desenho_topologia.place(relx=0.01, rely=0.08, relheight=0.91, relwidth=0.98)
        self.desenho_topologia.configure(background="white")
        self.desenho_topologia.configure(borderwidth="2")
        self.desenho_topologia.configure(insertbackground="black")
        self.desenho_topologia.configure(relief=RIDGE)
        self.desenho_topologia.configure(selectbackground="#c4c4c4")
        self.desenho_topologia.configure(selectforeground="black")
        self.desenho_topologia.configure(width=806)

        """
        NOTEBOOK CONFIGURAÇÕES
        """
        self.nb2 = ttk.Notebook(self.fr_configuracoes)
        self.nb2.place(relx=0.0, rely=0.0, relheight=0.99, relwidth=0.99)
        self.nb2.configure(width=814)
        self.nb2.configure(takefocus="")
        self.fr_algoritmos = ttk.Frame(self.nb2)
        self.nb2.add(self.fr_algoritmos, padding=3)
        self.nb2.tab(0, text="Algoritmos",underline="-1",)
        self.fr_chamadas = ttk.Frame(self.nb2)
        self.nb2.add(self.fr_chamadas, padding=3)
        self.nb2.tab(1, text="Chamadas", underline="-1", )
        """
        self.fr_origem_destino = ttk.Frame(self.nb2)
        self.nb2.add(self.fr_origem_destino, padding=3)
        self.nb2.tab(2, text="Orig. -> Dest.", underline="-1",)
        """
        """
        ABA CONFIGURAÇÕES -> ABA ALGORITMOS
        """
        self.chk_dijkstra = ttk.Checkbutton(self.fr_algoritmos)
        self.chk_dijkstra.place(relx=0.01, rely=0.02, relwidth=0.08, relheight=0.0, height=21)
        self.chk_dijkstra.configure(variable=op_dijkstra)
        self.chk_dijkstra.configure(takefocus="")
        self.chk_dijkstra.configure(text='''Dijkstra''')
        """
        ABA CONFIGURAÇÕES -> ABA CHAMADAS
        """
        self.lbl_num_chamadas = ttk.Label(self.fr_chamadas)
        self.lbl_num_chamadas.place(relx=0.01, rely=0.02, relwidth=0.16)
        self.lbl_num_chamadas.configure(text="Número de chamadas")
        self.txt_num_chamadas = ttk.Entry(self.fr_chamadas)
        self.txt_num_chamadas.place(relx=0.15, rely=0.02)

        self.lbl_lambda = ttk.Label(self.fr_chamadas)
        self.lbl_lambda.place(relx=0.01, rely=0.12, relwidth=0.16)
        self.lbl_lambda.configure(text="Comprimentos de onda")
        self.txt_lambda = ttk.Entry(self.fr_chamadas)
        self.txt_lambda.place(relx=0.15, rely=0.12)

        """
        ABA SAÍDA
        """
        self.fr_salvar = ttk.Frame(self.fr_saida)
        self.fr_salvar.place(relx=0.01, rely=0.02, relheight=0.26, relwidth=0.23)

        self.fr_salvar.configure(relief=GROOVE)
        self.fr_salvar.configure(borderwidth="2")
        self.fr_salvar.configure(relief=GROOVE)
        self.fr_salvar.configure(width=185)

        self.lbl_salvar = ttk.Label(self.fr_salvar)
        self.lbl_salvar.place(relx=0.11, rely=0.07, height=19, width=142)
        self.lbl_salvar.configure(background="#d9d9d9")
        self.lbl_salvar.configure(foreground="#000000")
        self.lbl_salvar.configure(relief=FLAT)
        self.lbl_salvar.configure(text='''Escolha o local do arquivo''')

        self.lbl_local = ttk.Label(self.fr_salvar)
        self.lbl_local.place(relx=0.05, rely=0.3, height=19, width=32)
        self.lbl_local.configure(background="#d9d9d9")
        self.lbl_local.configure(foreground="#000000")
        self.lbl_local.configure(relief=FLAT)
        self.lbl_local.configure(text='''Local''')

        self.txt_local = ttk.Entry(self.fr_salvar)
        self.txt_local.place(relx=0.27, rely=0.3, relheight=0.16, relwidth=0.68)
        self.txt_local.configure(takefocus="")
        self.txt_local.configure(cursor="ibeam")

        self.btn_salvar = ttk.Button(self.fr_salvar)
        self.btn_salvar.place(relx=0.27, rely=0.59, height=25, width=76)
        self.btn_salvar.configure(takefocus="")
        self.btn_salvar.configure(text='''Salvar''')
        self.btn_salvar.configure(command=self.g.set_matriz)

        """
        ABA SIMULAR
        """
        self.btn_simular = ttk.Button(self.fr_simular)
        self.btn_simular.place(relx=0.01, rely=0.02, height=25, width=106)
        self.btn_simular.configure(takefocus="")
        self.btn_simular.configure(text='''Simular''')
        self.btn_simular.configure(command=self.simulacao)

        self.novo_interacoes()
Пример #29
0
def click():
    global entry_x, entry_y, mouse
    mouse.click(int(entry_x.get()), int(entry_y.get()))
    entry_x.delete(0, 'end')
    entry_y.delete(0, 'end')


p = tk.Tk()
p.attributes('-type', 'dialog')
p.wm_title("Coordinate clicker")

label = ttk.Label(p, text="loading...", font=("Roboto", 12))
label.configure(anchor="center")
label.pack(side="top", fill=tk.BOTH, pady=5)

frame = ttk.Frame(p)
frame.pack(fill="x", pady=5)
label_x = ttk.Label(frame, text="X:", font=("Roboto", 12)).grid(row=0,
                                                                column=0)
entry_x = ttk.Entry(frame, width=4)
entry_x.grid(row=0, column=1)
label_y = ttk.Label(frame, text="Y:", font=("Roboto", 12)).grid(row=0,
                                                                column=2)
entry_y = ttk.Entry(frame, width=4)
entry_y.grid(row=0, column=3)
button_click = ttk.Button(frame, text="Click", command=click, width=5)
button_click.grid(row=0, column=4)

button = ttk.Button(p, text="Close", command=p.destroy)
button.pack(side="bottom")
    def __init__(self,
                 master=None,
                 year=None,
                 month=None,
                 firstweekday=calendar.MONDAY,
                 locale=None,
                 activebackground='#b1dcfb',
                 activeforeground='black',
                 selectbackground='#003eff',
                 selectforeground='white',
                 command=None,
                 borderwidth=2,
                 relief="solid",
                 on_click_month_button=None):
        """
        WIDGET OPTIONS

            locale, firstweekday, year, month, selectbackground,
            selectforeground, activebackground, activeforeground, 
            command, borderwidth, relief, on_click_month_button
        """

        if year is None:
            year = self.datetime.now().year

        if month is None:
            month = self.datetime.now().month

        self._selected_date = None

        self._sel_bg = selectbackground
        self._sel_fg = selectforeground

        self._act_bg = activebackground
        self._act_fg = activeforeground

        self.on_click_month_button = on_click_month_button

        self._selection_is_visible = False
        self._command = command

        ttk.Frame.__init__(self,
                           master,
                           borderwidth=borderwidth,
                           relief=relief)

        self.bind("<FocusIn>",
                  lambda event: self.event_generate('<<DatePickerFocusIn>>'))
        self.bind("<FocusOut>",
                  lambda event: self.event_generate('<<DatePickerFocusOut>>'))

        self._cal = get_calendar(locale, firstweekday)

        # custom ttk styles
        style = ttk.Style()
        style.layout('L.TButton', ([('Button.focus', {
            'children': [('Button.leftarrow', None)]
        })]))
        style.layout('R.TButton', ([('Button.focus', {
            'children': [('Button.rightarrow', None)]
        })]))

        self._font = tkFont.Font()

        self._header_var = StringVar()

        # header frame and its widgets
        hframe = ttk.Frame(self)
        lbtn = ttk.Button(hframe,
                          style='L.TButton',
                          command=self._on_press_left_button)
        lbtn.pack(side=LEFT)

        self._header = ttk.Label(hframe,
                                 width=15,
                                 anchor=CENTER,
                                 textvariable=self._header_var)
        self._header.pack(side=LEFT, padx=12)

        rbtn = ttk.Button(hframe,
                          style='R.TButton',
                          command=self._on_press_right_button)
        rbtn.pack(side=LEFT)
        hframe.grid(columnspan=7, pady=4)

        self._day_labels = {}

        days_of_the_week = self._cal.formatweekheader(3).split()

        for i, day_of_the_week in enumerate(days_of_the_week):
            Tkinter.Label(self, text=day_of_the_week,
                          background='grey90').grid(row=1,
                                                    column=i,
                                                    sticky=N + E + W + S)

        for i in range(6):
            for j in range(7):
                self._day_labels[i,
                                 j] = label = Tkinter.Label(self,
                                                            background="white")

                label.grid(row=i + 2, column=j, sticky=N + E + W + S)
                label.bind(
                    "<Enter>", lambda event: event.widget.configure(
                        background=self._act_bg, foreground=self._act_fg))
                label.bind(
                    "<Leave>",
                    lambda event: event.widget.configure(background="white"))

                label.bind("<1>", self._pressed)

        # adjust its columns width
        font = tkFont.Font()
        maxwidth = max(font.measure(text) for text in days_of_the_week)
        for i in range(7):
            self.grid_columnconfigure(i, minsize=maxwidth, weight=1)

        self._year = None
        self._month = None

        # insert dates in the currently empty calendar
        self._build_calendar(year, month)