Example #1
0
class Example(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI()

    def initUI(self):
        self.parent.title("Listbox")
        self.pack(fill=BOTH, expand=1)

        acts = ['Scarlett Johansson', 'Rachel Weiss',
            'Natalie Portman', 'Jessica Alba']

        lb = Listbox(self)
        for i in acts:
            lb.insert(END, i)

        lb.bind("<<ListboxSelect>>", self.onSelect)

        lb.place(x=20, y=20)

        self.var = StringVar()
        self.label = Label(self, text=0, textvariable=self.var)
        self.label.place(x=20, y=210)

    def onSelect(self, val):

        sender = val.widget
        idx = sender.curselection()
        value = sender.get(idx)

        self.var.set(value)
Example #2
0
    def initUI(self):
        self.username = ''
        self.r = praw.Reddit(USERAGENT)
        self.parent.title("")
        self.style = Style()
        self.style.theme_use("clam")
        self.pack(fill=BOTH, expand = 1)

        self.labelU = Label(self, text="U:")
        self.labelP = Label(self, text="P:")
        
        self.entryUsername = Entry(self)
        self.entryUsername.config(relief='flat')
        self.entryUsername.focus_set()
        self.entryUsername.bind('<Return>', lambda event: self.login(self.entryUsername.get()))
        self.entryUsername.bind('<Up>', lambda event: self.entryUsername.insert(0, self.username))

        self.quitbutton = Button(self, text="Quit", command= lambda: self.quit())
        self.quitbutton.config(width=6)
        
    
        self.labelKarma = Label(self, text = '•')
        self.labelKarma.grid(row = 3, column = 1)


        self.labelU.grid(row=0, column=0)
        self.entryUsername.grid(row=0, column=1)
        self.quitbutton.grid(row=2, column=1, pady=4)

        self.usernamelabel = Label(self, text='')
        self.usernamelabel.grid(row=1, column=1)
Example #3
0
  def initialize_ui(self):
    default_padding = {'padx': 10, 'pady' : 10}

    customer_frame = Frame(self)
    self.customer_id_label = Label(customer_frame, text = "Customer id:", style="BW.TLabel")
    self.customer_id_label.pack(default_padding, side = LEFT)

    self.customer_id_value = Label(customer_frame,style="BW.TLabel")
    self.customer_id_value["textvariable"] = self.controller.customer_id
    self.customer_id_value.pack(default_padding, side = LEFT)

    customer_frame.pack(expand = True, fill = "x")

    self.take_picture_frame = Frame(self, border = 10)
    
    self.picture_mode = IntVar()
    Radiobutton(self.take_picture_frame, text = "Light", variable = self.picture_mode, value = 1).pack(side = LEFT)
    Radiobutton(self.take_picture_frame, text = "Dark", variable = self.picture_mode, value = 2).pack(side = LEFT)
    
    self.button_take_picture = Button(self.take_picture_frame, text = "Take picture", command = self.take_picture)
    self.button_take_picture.pack(expand = True, fill = "x", side = BOTTOM)

    self.take_picture_frame.pack(expand = True)
    
    self.button_update = Button(self, text = "Update", command = self.controller.run_update_script)
    self.button_update.pack(expand = True, fill = "x")
Example #4
0
class OkFrame(MessageFrame):
    def __init__(self, master, config):
        super(OkFrame, self).__init__(master, config)

        if config.full_screen:
            self._make_full(master)

        self.master.grid_rowconfigure(0, weight=1)
        self.master.grid_rowconfigure(1, weight=1)
        self.master.grid_columnconfigure(0, weight=1)

        self._frame_lbl = Label(
            self.master,
            text='',
            anchor='center',
            font=self._config.item_font
        )
        self._frame_lbl.grid(row=0, column=0, sticky='snew')

        self._next_btn = Button(
            self.master,
            text='OK',
            command=self._next_cmd
        )
        self._next_btn.grid(row=1, column=0, sticky='snew')

    def show(master, config, msg):
        new_window = Toplevel(master)
        dlg = OkFrame(new_window, config)
        dlg._frame_lbl['text'] = msg

    def _next_cmd(self):
        self._master.destroy()
Example #5
0
class Example(Frame):
    def __init__(self, parent):
        Frame.__init__(self, parent)
        self.parent = parent
        self.initUI()

    def initUI(self):
        self.parent.title("Listbox")
        self.pack(fill=BOTH, expand=1)

        acts = ["Scarlett Johansson", "Rachel Weiss", "Natalie Portman", "Jessica Alba", "Angelina jolie", "Emma Stone", "Sandra Bullock", "Julia Roberts",
        "Jennifer Lawrence", "Mila Kunis", "Jennifer Aniston", "Charlize Theron", "Cameron Diaz", "Nicole Kidman", "Meryl Streep", "Reese Witherspoon"]

        lb = Listbox(self, selectmode="multiple")
        for i in acts:
            lb.insert(END, i)

        lb.bind("<<ListboxSelect>>", self.onSelect)

        lb.pack(pady=15)

        self.var = StringVar()
        self.label = Label(self, text=0, textvariable=self.var)
        self.label.pack()

    def onSelect(self, val):
        sender = val.widget
        idx = sender.curselection()
        value = sender.get(idx)
        self.var.set(value)
Example #6
0
    def initUI(self):

        self.parent.title("Windows")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        self.columnconfigure(1, weight=1)
        self.columnconfigure(3, pad=7)
        self.rowconfigure(3, weight=1)
        self.rowconfigure(5, pad=7)

        lbl = Label(self, text="Windows")
        lbl.grid(sticky=W, pady=4, padx=5)

        area = Text(self)
        area.grid(row=1, column=0, columnspan=2, rowspan=4, padx=5, sticky=E + W + S + N)

        abtn = Button(self, text="Activate")
        abtn.grid(row=1, column=3)

        cbtn = Button(self, text="Close")
        cbtn.grid(row=2, column=3, pady=4)

        hbtn = Button(self, text="Help")
        hbtn.grid(row=5, column=0, padx=5)

        obtn = Button(self, text="OK")
        obtn.grid(row=5, column=3)
    def create_widgets(self):
        ''' Creates appropriate widgets on this frame.
        '''
        self.columnconfigure(0, weight=1)
        self.rowconfigure(3, weight=1)
        frame_for_save_btn = Frame(self)
        frame_for_save_btn.columnconfigure(1, weight=1)
        self.status_lbl = Label(frame_for_save_btn, text='')
        self.status_lbl.grid(row=0, column=1, sticky=N+W)
        save_solution_btn = Button(frame_for_save_btn, text='Save solution',
                                   command=self.on_save_solution)
        save_solution_btn.grid(row=1, column=0, sticky=W+N, padx=5, pady=5)
        self.progress_bar = Progressbar(frame_for_save_btn,
                                        mode='determinate', maximum=100)
        self.progress_bar.grid(row=1, column=1, sticky=W+E, padx=10, pady=5)

        frame_for_save_btn.grid(sticky=W+N+E+S, padx=5, pady=5)

        frame_for_btns = Frame(self)
        self._create_file_format_btn('*.xlsx', 1, frame_for_btns, 0)
        self._create_file_format_btn('*.xls', 2, frame_for_btns, 1)
        self._create_file_format_btn('*.csv', 3, frame_for_btns, 2)
        self.solution_format_var.set(1)

        frame_for_btns.grid(row=1, column=0, sticky=W+N+E+S, padx=5, pady=5)
        self.data_from_file_lbl = Label(self, text=TEXT_FOR_FILE_LBL, anchor=W,
                                        justify=LEFT,
                                        wraplength=MAX_FILE_PARAMS_LBL_LENGTH)
        self.data_from_file_lbl.grid(row=2, column=0, padx=5, pady=5,
                                     sticky=W+N)

        self.solution_tab = SolutionFrameWithText(self)
        self.solution_tab.grid(row=3, column=0, sticky=W+E+S+N, padx=5, pady=5)
Example #8
0
 class DateWidget(Frame):
     """Gets a date from the user."""
     def __init__(self, master):
         """Make boxes, register callbacks etc."""
         Frame.__init__(self, master)
         self.label = Label(self, text="När är du född?")
         self.label.pack()
         self.entry_text = StringVar()
         self.entry_text.trace("w", lambda *args: self.onEntryChanged())
         self.entry = Entry(self, width=date_entry_width,
              textvariable=self.entry_text)
         self.entry.insert(0, "ÅÅÅÅ-MM-DD")
         self.entry.pack(pady=small_pad)
         self.button = Button(self, text="Uppdatera",
              command=lambda: self.onDateChanged())
         self.button.pack()
         self.entry.focus_set()
         self.entry.select_range(0, END)
         self.entry.bind("<Return>", lambda x: self.onDateChanged())
     def setListener(self, pred_view):
         """Select whom to notify when a new date is entered."""
         self.pred_view = pred_view
     def onDateChanged(self):
         """Notifies the PredictionWidget that the date has been changed."""
         try:
             date = datetime.datetime.strptime(self.entry.get(),
                  "%Y-%m-%d").date()
             self.pred_view.update(date)
         except ValueError:
             self.entry.configure(foreground="red")
     def onEntryChanged(self):
         """Reset the text color."""
         self.entry.configure(foreground="")
Example #9
0
class StatusBar(TagReaderListener):
    def __init__(self, master):
        super().__init__()
        self.label = Label(master, text='', anchor=W)
        self.label.pack()
        self.index = 0
        self.expected_count = 0

    def start_task(self, text):
        self.label['text'] = text + "..."

    def task_complete(self):
        self.label['text'] += 'Done'

    def read_complete(self, elapsed_time):
        self.set("{} files read in {} milliseconds".format(self.expected_count, round(elapsed_time, 2)))

    def read_start(self, count):
        self.expected_count = count
        self.index = 0
        self.set("Reading tags in {} files".format(self.expected_count))

    def file_read(self, file):
        self.index += 1
        percent = round(100 * self.index / self.expected_count, 2)
        self.set("Reading tags in {} files: {}%".format(self.expected_count, percent))

    def counting_files(self):
        self.set("Counting files...")

    def set(self, text: str):
        self.label['text'] = text
Example #10
0
 class PredictionWidget(Frame):
     """Shows a prediction to the user."""
     def __init__(self, master):
         """Make boxes, register callbacks etc."""
         Frame.__init__(self, master)
         self.active_category = StringVar()
         self.bind("<Configure>", self.onResize)
         self.date = None
         self.predictor = Predictor()
         self.category_buttons = self.createCategoryButtons()
         self.text = Label(self, justify=CENTER, font="Arial 14")
     def createCategoryButtons(self):
         """Create the buttons used to choose category. Return them."""
         result = []
         icons = self.readIcons()
         categories = self.predictor.categories()
         for i in categories:
             if i in icons:
                 icon = icons[i]
             else:
                 icon = icons["= default ="]
             category_button = Radiobutton(self, image=icon,
                  variable=self.active_category, value=i, indicatoron=False,
                  width=icon_size, height=icon_size, command=self.update)
             category_button.image_data = icon
             result.append(category_button)
         self.active_category.set(categories[0])
         return result
     def readIcons(self):
         """Read the gui icons from disk. Return them."""
         result = {}
         categories = open(nextToThisFile("icons.txt")).read().split("\n\n")
         for i in categories:
             category_name, file_data = i.split("\n", maxsplit=1)
             image = PhotoImage(data=file_data)
             result[category_name] = image
         return result
     def onResize(self, event):
         """Rearrange the children when the geometry of self changes."""
         if event.widget == self:
             center = (event.width / 2, event.height / 2)
             radius = min(center) - icon_size / 2
             self.text.place(anchor=CENTER, x=center[0], y=center[1])
             for i, j in enumerate(self.category_buttons):
                 turn = 2 * math.pi
                 angle = turn * (1 / 4 - i / len(self.category_buttons))
                 j.place(anchor=CENTER,
                         x=center[0] + math.cos(angle) * radius,
                         y=center[1] - math.sin(angle) * radius)
     def update(self, date=None):
         """Change contents based on circumstances. Set date if given."""
         if date:
             self.date = date
         if self.date:
             predictions = self.predictor.predict(self.date)
             prediction = predictions[self.active_category.get()]
             prediction = textwrap.fill(prediction, width=20)
         else:
             prediction = ""
         self.text.configure(text=prediction)
Example #11
0
    def __init__(self, url):
        self.url = url

        self.root = Tk()
        self.root.title("验证码")

        while True:
            try:
                image_bytes = urlopen(self.url).read()
                break
            except socket.timeout:
                print('获取验证码超时:%s\r\n重新获取.' % (self.url))
                continue
            except urllib.error.URLError as e:
                if isinstance(e.reason, socket.timeout):
                    print('获取验证码超时:%s\r\n重新获取.' % (self.url))
                    continue
        # internal data file
        data_stream = io.BytesIO(image_bytes)
        # open as a PIL image object
        self.pil_image = Image.open(data_stream)
        # convert PIL image object to Tkinter PhotoImage object
        self.tk_image = ImageTk.PhotoImage(self.pil_image)
        self.label = Label(self.root, image=self.tk_image, background='brown')
        self.label.pack(padx=5, pady=5)
        self.button = Button(self.root, text="刷新验证码", command=self.refreshImg)
        self.button.pack(padx=5, pady=5)

        randCodeLable = Label(self.root, text="验证码:")
        randCodeLable.pack(padx=5, pady=5)
        self.randCode = Entry(self.root)
        self.randCode.pack(padx=5, pady=5)

        self.loginButton = Button(self.root, text="登录", default=tkinter.ACTIVE)
        self.loginButton.pack(padx=5, pady=5)
Example #12
0
    def create_widgets(self):  # Call from override, if any.
        # Bind to self widgets needed for entry_ok or unittest.
        self.frame = frame = Frame(self, padding=10)
        frame.grid(column=0, row=0, sticky='news')
        frame.grid_columnconfigure(0, weight=1)

        entrylabel = Label(frame, anchor='w', justify='left',
                           text=self.message)
        self.entryvar = StringVar(self, self.text0)
        self.entry = Entry(frame, width=30, textvariable=self.entryvar)
        self.entry.focus_set()
        self.error_font = Font(name='TkCaptionFont',
                               exists=True, root=self.parent)
        self.entry_error = Label(frame, text=' ', foreground='red',
                                 font=self.error_font)
        self.button_ok = Button(
                frame, text='OK', default='active', command=self.ok)
        self.button_cancel = Button(
                frame, text='Cancel', command=self.cancel)

        entrylabel.grid(column=0, row=0, columnspan=3, padx=5, sticky=W)
        self.entry.grid(column=0, row=1, columnspan=3, padx=5, sticky=W+E,
                        pady=[10,0])
        self.entry_error.grid(column=0, row=2, columnspan=3, padx=5,
                              sticky=W+E)
        self.button_ok.grid(column=1, row=99, padx=5)
        self.button_cancel.grid(column=2, row=99, padx=5)
Example #13
0
    def __init__(self, pipepanel, pipeline_name, *args, **kwargs) :
        PipelineFrame.__init__(self, pipepanel, pipeline_name, *args, **kwargs)
        self.pairs = None
        
        eframe = self.eframe = LabelFrame(self,text="Options") 
        #,fg=textLightColor,bg=baseColor)
        eframe.grid( row=5, column=1, sticky=W, columnspan=7, padx=10, pady=5 )
        
        label = Label(eframe,text="Pipeline")#,fg=textLightColor,bg=baseColor)
        label.grid(row=3,column=0,sticky=W,padx=10,pady=5)

        PipelineLabels = ['Initial QC', 
			  'Germline',
			  'Somatic Tumor-Normal',
                          'Somatic Tumor-Only']
        Pipelines=["initialqcgenomeseq",
                   "wgslow", 
		   'wgs-somatic',
                   'wgs-somatic-tumoronly']

        self.label2pipeline = { k:v for k,v in zip(PipelineLabels, Pipelines)}
        PipelineLabel = self.PipelineLabel = StringVar()
        Pipeline = self.Pipeline = StringVar()
        PipelineLabel.set(PipelineLabels[0])
        
        #om = OptionMenu(eframe, Pipeline, *Pipelines, command=self.option_controller)
        om = OptionMenu(eframe, PipelineLabel, *PipelineLabels, command=self.option_controller)
        om.config()#bg = widgetBgColor,fg=widgetFgColor)
        om["menu"].config()#bg = widgetBgColor,fg=widgetFgColor)
        #om.pack(side=LEFT,padx=20,pady=5)
        om.grid(row=3,column=1,sticky=W,padx=10,pady=5)
Example #14
0
 def build_widgets(self):
     "Build the various widgets that will be used in the program."
     # Create processing frame widgets.
     self.processing_frame = LabelFrame(self, text='Processing Mode:')
     self.mode_var = StringVar(self, 'encode')
     self.decode_button = Radiobutton(self.processing_frame,
                                      text='Decode Cipher-Text',
                                      command=self.handle_radiobuttons,
                                      value='decode',
                                      variable=self.mode_var)
     self.encode_button = Radiobutton(self.processing_frame,
                                      text='Encode Plain-Text',
                                      command=self.handle_radiobuttons,
                                      value='encode',
                                      variable=self.mode_var)
     self.freeze_var = BooleanVar(self, False)
     self.freeze_button = Checkbutton(self.processing_frame,
                                      text='Freeze Key & Primer',
                                      command=self.handle_checkbutton,
                                      offvalue=False,
                                      onvalue=True,
                                      variable=self.freeze_var)
     # Create encoding frame widgets.
     self.encoding_frame = LabelFrame(self, text='Encoding Options:')
     self.chain_size_label = Label(self.encoding_frame, text='Chain Size:')
     self.chain_size_entry = Entry(self.encoding_frame)
     self.plain_text_label = Label(self.encoding_frame, text='Plain-Text:')
     self.plain_text_entry = Entry(self.encoding_frame)
     # Create input frame widgets.
     self.input_frame = LabelFrame(self, text='Input Area:')
     self.input_text = ScrolledText(self.input_frame, **self.TEXT)
     # Create output frame widgets.
     self.output_frame = LabelFrame(self, text='Output Area:')
     self.output_text = ScrolledText(self.output_frame, **self.TEXT)
Example #15
0
 def setup_gui(self):
     self.parent.title("Stein - Saks - Papir")
     self.style.theme_use("default")
     self.pack(fill=BOTH, expand=1)
     # Label for rapportering
     label = Label(self.parent, textvariable=self.resultat_label)
     label.place(x=800, y=50)
     # Buttons
     # Disse fyrer av metoden self.arranger_enkeltspill som er
     # definert i klassen. Denne metoden tar aksjonen til mennesket
     # som startup, og gjennomfoerer spillet
     # Samme type oppfoersel for de tre aksjons-knappene
     rock_button = Button(self, text="Stein",
                          command=lambda: self.arranger_enkeltspill(Action("rock")))
     rock_button.place(x=800, y=400)
     scissors_button = Button(self, text="Saks",
                              command=lambda: self.arranger_enkeltspill(Action("scissor")))
     scissors_button.place(x=900, y=400)
     paper_button = Button(self, text="Papir",
                           command=lambda: self.arranger_enkeltspill(Action("paper")))
     paper_button.place(x=1000, y=400)
     # quit_button avslutter GUI'et naar den trykkes
     quit_button = Button(self, text="Quit", command=self.quit)
     quit_button.place(x=1000, y=450)
     # Embedde en graf i vinduet for aa rapportere fortloepende score
     self.fig = FigureCanvasTkAgg(pylab.figure(), master=self)
     self.fig.get_tk_widget().grid(column=0, row=0)
     self.fig.show()
Example #16
0
    def initUI(self):
        self.parent.title("Windows")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        self.columnconfigure(1, weight=1)
        self.columnconfigure(3, pad=7)
        self.rowconfigure(6, weight=1)
        self.rowconfigure(5, pad=7)

        lbl = Label(self, text="BookManager")
        lbl.grid(sticky=W, pady=4, padx=5)

        self.area = Text(self) #WHITE TEXT BOX
        self.area.grid(row=1, column=0, columnspan=3, rowspan=4,
            padx=5, sticky=E+W+S+N)

        abtn = Button(self, text="add", command=self.press_add)
        abtn.grid(row=1, column=3)

        srcbtn = Button(self, text="search", command=self.press_search)
        srcbtn.grid(row=2, column=3, pady=3)

        rbtn = Button(self, text="remove", command=self.press_remove)
        rbtn.grid(row=3, column=3, pady=3)

        sbtn = Button(self, text="show all", command=self.press_show)
        sbtn.grid(row=4, column=3, pady=3)
Example #17
0
class Form(Frame):
  
    def __init__(self, parent):
        Frame.__init__(self, parent)   
         
        self.parent = parent

        self.parent.title("Example Form")
        self.pack(fill=BOTH, expand=True)

        f = Frame(self)
        f.pack(fill=X)

        l = Label(f, text='First Name', width=10)
        l.pack(side=LEFT, padx=5, pady=5)
       
        self.firstName = Entry(f)
        self.firstName.pack(fill=X, padx=5, expand=True)
        
        f = Frame(self)
        f.pack(fill=X)
        
        l = Label(f, text='Last Name', width=10)
        l.pack(side=LEFT, padx=5, pady=5)

        self.lastName = Entry(f)
        self.lastName.pack(fill=X, padx=5, expand=True)
        
        f = Frame(self)
        f.pack(fill=X)

        l = Label(f, text='Full Name', width=10)
        l.pack(side=LEFT, padx=5, pady=5)

        self.fullName = Label(f, text='ALEX POOPKIN', width=10)
        self.fullName.pack(fill=X, padx=5, expand=True)

        f = Frame(self)
        f.pack(fill=X)

        l = Label(f, text='', width=10)
        l.pack(side=LEFT, padx=5, pady=0)

        self.errorMessage = Label(f, text='Invalid character int the name!', foreground='red', width=30)
        self.errorMessage.pack(fill=X, padx=5, expand=True)

        f = Frame(self)
        f.pack(fill=X)

        b = Button(f, text='Close', command=lambda : self.parent.quit())
        b.pack(side=RIGHT, padx=5, pady=10)
        b['default'] = ACTIVE
        b.focus_set()

        self.clearButton = Button(f, text='Clear')
        self.clearButton.pack(side=RIGHT, padx=5, pady=10)
        self.clearButton['state'] = DISABLED

        self.sendButton = Button(f, text='Send')
        self.sendButton.pack(side=RIGHT, padx=5, pady=10)
Example #18
0
 def insert_entry_field(self, txt):
     frame = Frame(self.frame)
     frame.pack(fill="x")
     label = Label(frame, text=txt, width=6)
     label.pack(side="left", anchor="n", padx=5, pady=5)
     entry = Entry(frame)
     entry.pack(fill="x", padx=5, pady=5, expand=True)
     self.entries["Entry"][txt] = entry
Example #19
0
 def __init__(self, parent, url=None, buttonSEC=False, buttonRSS=False):
     super(DialogURL, self).__init__(parent)
     self.parent = parent
     parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)", parent.geometry())
     dialogX = int(parentGeometry.group(3))
     dialogY = int(parentGeometry.group(4))
     self.accepted = False
     self.url = None
     self.transient(self.parent)
     self.title("Enter URL")
     self.urlVar = StringVar()
     self.urlVar.set(url if url is not None else "http://")
     
     frame = Frame(self)
     urlLabel = Label(frame, text=_("URL:"), underline=0)
     urlEntry = Entry(frame, textvariable=self.urlVar, width=60)
     urlEntry.focus_set()
     okButton = Button(frame, text=_("OK"), command=self.ok)
     cancelButton = Button(frame, text=_("Cancel"), command=self.close)
     if buttonSEC:
         usSecButton = Button(frame, text=_("SEC search"), command=self.usSec)
         usSecButton.grid(row=1, column=1, sticky=W, pady=3)
         ToolTip(usSecButton, text=_("Opens US SEC Edgar Company Search (in web browser)\n\n"
                                  "(1) Find the company in web browser,\n"
                                  "(2) Click 'documents' button for desired filing,\n"
                                  "(3) Find 'data files' panel, instance document row, 'document' column,\n"
                                  "(4) On instance document file name, right-click browser menu: 'copy shortcut',\n"
                                  "(5) Come back to this dialog window,\n"
                                  "(6) Ctrl-v (paste) shortcut into above URL text box,\n"
                                  "(7) Click ok button to load instance document"),
                                  wraplength=480)
     if buttonRSS:
         rssButton = Button(frame, text=_("SEC RSS"), command=self.rssFeed)
         rssButton.grid(row=1, column=1, pady=3)
         ToolTip(rssButton, text=_("Opens current US SEC Edgar RSS feed"),
                                  wraplength=480)
     urlLabel.grid(row=0, column=0, sticky=W, pady=3, padx=3)
     urlEntry.grid(row=0, column=1, columnspan=3, sticky=EW, pady=3, padx=3)
     okButton.grid(row=1, column=2, sticky=E, pady=3)
     ToolTip(okButton, text=_("Opens above URL from web cache, downloading to cache if necessary"), wraplength=240)
     cancelButton.grid(row=1, column=3, sticky=EW, pady=3, padx=3)
     ToolTip(cancelButton, text=_("Cancel operation"))
                 
     frame.grid(row=0, column=0, sticky=(N,S,E,W))
     frame.columnconfigure(1, weight=1)
     window = self.winfo_toplevel()
     window.columnconfigure(0, weight=1)
     self.geometry("+{0}+{1}".format(dialogX+50,dialogY+100))
     
     self.bind("<Alt-u>", lambda *ignore: urlEntry.focus_set())
     self.bind("<Return>", self.ok)
     self.bind("<Escape>", self.close)
     
     self.protocol("WM_DELETE_WINDOW", self.close)
     self.grab_set()
     self.wait_window(self)
Example #20
0
class Main(Frame):
    """Main class for our browser.
        Note that we inherit from Frame, making this a Frame object.
    """
    def __init__(self, master):
        Frame.__init__(self, master)
        self.master = master
        self.master.title("Browser")
        self.header = {"User-Agent":"Tkinter Browser 0.1"}

        # Here we make our widgets.
        self.top_frame = Frame(self)
        self.url_frame = Frame(self.top_frame)
        self.url_label = Label(self.url_frame, text="Url: ", anchor="n")
        self.url_entry = Entry(self.url_frame, width=80)
        self.url_button = Button(self.url_frame, text="Go", command=self.go_button)
        self.bottom_frame = Frame(self)
        self.text_field = Text(self.bottom_frame)

        #Here we pack our widgets.
        self.top_frame.pack(side="top", padx=15, pady=15)
        self.url_frame.pack(anchor="center")
        self.bottom_frame.pack(side="bottom", fill="both", expand=True)
        self.text_field.pack(side="bottom", fill="both", expand=True)
        self.url_label.pack(side="left")
        self.url_entry.pack(side="left", fill="x", expand=True)
        self.url_button.pack(side="left", padx=5)
        self.text_field.config(state="disabled", padx=5, pady=5)

    def go_button(self):
        url = self.url_entry.get()
        if url:
            if "http://" not in url:
                url = "http://"+url
            page_text = self.get_page(url)
            self.text_field.config(state="normal")
            self.text_field.delete(1.0, "end")
            self.text_field.insert("end", page_text)
            self.text_field.config(state="disable")

    def get_page(self, url):
        s = requests.Session()
        resp = s.get(url, headers=self.header)
        data = resp.text
        soup = bs(data, "html.parser")
        page_text = soup.find_all(text=True)
        page_text = filter(self.visible, page_text)
        return "".join([str(i)+'\n' for i in page_text])


    def visible(self, e):
        if e.parent.name in ('style', 'script', '[document]', 'head', 'title'):
            return False
        elif re.match('<!--.*-->', str(e.encode('utf-8'))):
            return False
        return True
Example #21
0
 def insert_text_field(self, txt, default=None):
     frame = Frame(self.frame)
     frame.pack(fill="x")
     label = Label(frame, text=txt, width=6)
     label.pack(side="left", anchor="n", padx=5, pady=5)
     entry = Text(frame)
     entry.pack(fill="both", pady=5, padx=5, expand=True)
     if default:
         entry.insert("end", default)
     self.entries["Text"][txt] = entry
Example #22
0
    def create_widgets(self):
        super().create_widgets()
        frame = self.frame
        pathlabel = Label(frame, anchor="w", justify="left", text="Help File Path: Enter URL or browse for file")
        self.pathvar = StringVar(self, self.filepath)
        self.path = Entry(frame, textvariable=self.pathvar, width=40)
        browse = Button(frame, text="Browse", width=8, command=self.browse_file)

        pathlabel.pack(anchor="w", padx=5, pady=3)
        self.path.pack(anchor="w", padx=5, pady=3)
        browse.pack(pady=3)
Example #23
0
 def insert_entry_field(self, txt, default=None, focus=False):
     frame = Frame(self.frame)
     frame.pack(fill="x")
     label = Label(frame, text=txt, width=6)
     label.pack(side="left", anchor="n", padx=5, pady=5)
     entry = Entry(frame)
     entry.pack(fill="x", padx=5, pady=5, expand=True)
     if default:
         entry.insert("end", default)
     if focus:
         entry.focus_force()
     self.entries["Entry"][txt] = entry
Example #24
0
class ConfirmFrame(MessageFrame):
    def __init__(self, master, config):
        super(ConfirmFrame, self).__init__(master, config)

        if config.full_screen:
            self._make_full(master)

        self.master.grid_rowconfigure(0, weight=1)
        self.master.grid_rowconfigure(1, weight=1)
        self.master.grid_columnconfigure(0, weight=1)
        self.master.grid_columnconfigure(1, weight=1)

        self._result = False

        self._frame_lbl = Label(
            self.master,
            text='',
            anchor='center',
            font=self._config.item_font
        )
        self._frame_lbl.grid(row=0, column=0, columnspan=2, sticky='snew')

        self._prev_btn = Button(
            self.master,
            text='Cancel',
            command=self._prev_cmd
        )
        self._prev_btn.grid(row=1, column=0, sticky='snew')

        self._next_btn = Button(
            self.master,
            text='OK',
            command=self._next_cmd
        )
        self._next_btn.grid(row=1, column=1, sticky='snew')

    def show(master, config, msg, ok_text, cancel_text):
        new_window = Toplevel(master)
        dlg = ConfirmFrame(new_window, config)
        dlg._frame_lbl['text'] = msg
        dlg._prev_btn['text'] = cancel_text
        dlg._next_btn['text'] = ok_text

        dlg.wait_window(new_window)

        return dlg._result

    def _prev_cmd(self):
        self._result = False
        self._master.destroy()
    def _next_cmd(self):
        self._result = True
        self._master.destroy()
Example #25
0
    def make_entry(self, label_text, var):
        '''Return (entry, label), .

        entry - gridded labeled Entry for text entry.
        label - Label widget, returned for testing.
        '''
        label = Label(self.top, text=label_text)
        label.grid(row=self.row, column=0, sticky="nw")
        entry = Entry(self.top, textvariable=var, exportselection=0)
        entry.grid(row=self.row, column=1, sticky="nwe")
        self.row = self.row + 1
        return entry, label
Example #26
0
    def initUI(self):

        self.parent.title("Book Manager")
        self.style = Style()
        self.style.theme_use("default")
        self.pack(fill=BOTH, expand=1)

        self.columnconfigure(0, pad=3)
        self.columnconfigure(1, pad=3)
        self.columnconfigure(2, pad=3)
        self.rowconfigure(0, pad=3)
        self.rowconfigure(1, pad=3)
        self.rowconfigure(2, pad=3)
        self.rowconfigure(3, pad=3)
        self.rowconfigure(4, pad=3)
        self.rowconfigure(5, pad=3)
        self.rowconfigure(6, pad=3)


        self.input_bname=''
        self.input_aname=''
        self.input_price=0
        self.delete=''

        lb_bookname = Label(self, text="bookname:")
        lb_bookname.grid(row=0, column =0 ,sticky=W, pady=4, padx=5)

        self.entry_bookname = Entry(self)
        self.entry_bookname.grid(row=0, column = 1 )

        lb_author = Label(self, text="author:")
        lb_author.grid(row=0, column =2,sticky=W, pady=4, padx=5)

        self.entry_author = Entry(self)
        self.entry_author.grid(row=0, column = 3 )


        lb_price = Label(self, text="price:")
        lb_price.grid(row=0, column =4 ,sticky=W, pady=4, padx=5)

        self.entry_price = Entry(self)
        self.entry_price.grid(row=0, column = 5 ,padx=15)


        abtn = Button(self, text="Add", command=lambda:self.clicked_add())
        abtn.grid(row=0, column=6)

        sbtn = Button(self, text="Serach", command = lambda:self.clicked_search())
        sbtn.grid(row=1, column=6, pady=4)

        dbtn = Button(self, text="Delete", command = lambda:self.clicked_delete())
        dbtn.grid(row=2, column=6, pady=4)

        self.lb = Listbox(self)

        self.lb.grid(row=3,column = 0, columnspan = 6,rowspan= 4, sticky = E+W+S+N)
        self.lb.bind("<<ListboxSelect>>", self.onSelect)
Example #27
0
    def initUI(self, mainFrame):
        """initialize the User Interface"""
        
        # styles
        style = Style()
        style.configure("GRN.TLabel", background="#ACF059")
        style.configure("GRN.TFrame", background="#ACF059")
        style.configure("BLK.TFrame", background="#595959")
        
        
        # create top frame
        topFrame = Frame(mainFrame, style="GRN.TFrame", padding=8)
        topFrame.pack(fill=BOTH, side=TOP)
        
        # create black border
        borderFrame = Frame(mainFrame, style="BLK.TFrame")
        borderFrame.pack(fill=BOTH, side=TOP)
        
        # create add player frame
        addPlayerFrame = Frame(mainFrame, padding=8)
        addPlayerFrame.pack(side=TOP)
        
        # create text field for add button
        self.nameFieldVar = StringVar()
        self.playerNameEntry = Entry(addPlayerFrame, textvariable = self.nameFieldVar)
        self.playerNameEntry.pack(side=LEFT)
        # create add player button
        addButton = Button(addPlayerFrame, text="Add player")
        addButton.pack(side=LEFT)
        
        # create choose game list
        self.currentGame = StringVar()
        self.currentGame.set(self.gameList[0])
        gameDropDown = OptionMenu(mainFrame, self.currentGame, self.gameList[0], *self.gameList)
        gameDropDown.pack(side=TOP)

        # create start game button
        startGameButton = Button(mainFrame, text="Start")
        
        startGameButton.bind("<Button-1>", self.startGame)
        startGameButton.pack(side=TOP)
        
        # create label and set text
        self.playerString = StringVar()
        self.playerString.set(self.buildPlayerHeaderString())
        headerLabel = Label(topFrame, textvariable=self.playerString, style="GRN.TLabel")
        headerLabel.pack(side=TOP)     
        addButton.bind("<Button-1>", self.onAddPlayerClick)
        self.playerNameEntry.bind("<Key>", self.onAddPlayerEnter)
        
        #set focus
        self.playerNameEntry.focus()
Example #28
0
 def add_field(self, widget, multiline=False, **kw):
     label_sticky = [tkinter.EW]
     widget_sticky = [tkinter.EW]
     if multiline:
         label_sticky.append(tkinter.N)
         widget_sticky.append(tkinter.NS)
     
     label = Label(self.master, **kw)
     label.grid(column=self.column + 0, sticky=label_sticky)
     row = grid_row(label)
     if multiline:
         self.master.rowconfigure(row, weight=1)
     widget.grid(row=row, column=self.column + 1, sticky=widget_sticky)
Example #29
0
class CopilotInnerFrame(CopilotBaseFrame):
    def __init__(self, master, config):
        super(CopilotInnerFrame, self).__init__(master, config)

        if config.full_screen:
            self._make_full(master)

        self.master.grid_rowconfigure(1, weight=1)
        self.master.grid_columnconfigure(1, weight=1)

        self._create_header()

        self._sb = Scrollbar(self._master, orient=VERTICAL)
        self._sb.grid(row=1, column=3, sticky='nse')

        self._next_hidden = False

    def _cmd_back(self):
        self._master.destroy()

    def _create_header(self):
        self.back_btn = Button(
            self._master,
            text='< Back',
            command=self._cmd_back
        )
        self.back_btn.grid(row=0, column=0, sticky='w')

        self._frame_lbl = Label(
            self.master,
            text='',
            anchor='center',
            font=self._config.item_font
        )
        self._frame_lbl.grid(row=0, column=1, sticky='ew')

        self._next_btn = Button(
            self.master,
            text='Next >'
        )
        self._next_btn.grid(row=0, column=2, sticky='e')

    def _hide_next(self):
        if not self._next_hidden:
            self._next_btn.grid_remove()
            self._next_hidden = True

    def _show_next(self):
        if self._next_hidden:
            self._next_btn.grid(row=0, column=2, sticky='e')
            self._next_hidden = False
Example #30
0
    def initUI(self):
        self.parent.title("")
        #self.style = Style()
        #self.style.theme_use("clam")
        #self.pack(fill=BOTH, expand = 1)

        self.labelU = Label(self, text="U:")
        self.labelP = Label(self, text="P:")

        self.mailrecipient = 'GoldenSights'
        
        self.entryUsername = Entry(self)
        self.entryUsername.focus_set()
        self.entryUsername.bind('<Return>', lambda event: self.entryPassword.focus_set())

        self.entryPassword = Entry(self)
        self.entryPassword.config(show='•')
        self.entryPassword.bind('<Return>', lambda event: self.login(self.entryUsername.get(), self.entryPassword.get()))

        self.newbutton = Button(self, text="Login", command= lambda: self.login(self.entryUsername.get(), self.entryPassword.get()))
        self.newbutton.bind('<Return>', lambda event: self.login(self.entryUsername.get(), self.entryPassword.get()))
        self.newbutton.config(width=6)
        self.quitbutton = Button(self, text="Quit", command= lambda: self.quit())
        self.quitbutton.config(width=6)
    
        self.labelU.grid(row=0, column=0,padx=0)
        self.entryUsername.grid(row=0, column=1)
        self.labelP.grid(row=1, column=0)
        self.entryPassword.grid(row=1, column=1, pady=4)
        self.newbutton.grid(row=2, column=1)
        self.quitbutton.grid(row=3, column=1, pady=4)

        self.labelErrorPointer = Label(self, text="◀")

        self.indicatorGreen = PhotoImage(file="indicatorGreen.gif")
        self.indicatorRed = PhotoImage(file="indicatorRed.gif")
        self.indicatorBlue = PhotoImage(file="indicatorBlue.gif")
        self.indicatorBlack = PhotoImage(file="indicatorBlack.gif")
        

        
        sw = self.parent.winfo_screenwidth()
        sh = self.parent.winfo_screenheight()


        w=400
        h=480
        x = (sw - w) / 2
        y = (sh - h) / 2

        self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y-50))
Example #31
0
    def _init_general(self):
        general_settings = Frame(self.notebook, padding=4)
        general_settings.columnconfigure(0, weight=1)
        self.notebook.add(general_settings,
                          text=_("General"),
                          sticky="ewsn",
                          padding=4)

        # ---- language

        self.lang = StringVar(self,
                              LANGUAGES[CONFIG.get("General", "language")])
        lang_frame = Frame(general_settings)
        Label(lang_frame, text=_("Language")).grid(row=0,
                                                   sticky="w",
                                                   padx=4,
                                                   pady=4)
        menu_lang = Menu(lang_frame, tearoff=False)
        Menubutton(lang_frame, menu=menu_lang, width=9,
                   textvariable=self.lang).grid(row=0,
                                                column=1,
                                                padx=8,
                                                pady=4)
        for lang in LANGUAGES.values():
            menu_lang.add_radiobutton(variable=self.lang,
                                      label=lang,
                                      value=lang,
                                      command=self.translate)
        # ---- gui toolkit
        self.gui = StringVar(self,
                             CONFIG.get("General", "trayicon").capitalize())
        gui_frame = Frame(general_settings)
        Label(gui_frame,
              text=_("GUI Toolkit for the system tray icon")).grid(row=0,
                                                                   column=0,
                                                                   padx=4,
                                                                   pady=4,
                                                                   sticky="w")
        menu_gui = Menu(gui_frame, tearoff=False)
        Menubutton(gui_frame, menu=menu_gui, width=9,
                   textvariable=self.gui).grid(row=0,
                                               column=1,
                                               padx=4,
                                               pady=4,
                                               sticky="w")
        for toolkit, b in TOOLKITS.items():
            if b:
                menu_gui.add_radiobutton(label=toolkit.capitalize(),
                                         value=toolkit.capitalize(),
                                         variable=self.gui,
                                         command=self.change_gui)
        # ---- opacity
        self.opacity = OpacityFrame(general_settings,
                                    CONFIG.getint("General", "opacity"))
        # ---- position
        frame_position = Frame(general_settings)
        self.position = StringVar(self, CONFIG.get("General", "position"))
        Label(frame_position,
              text=_("Default position of the notes")).grid(row=0,
                                                            columnspan=3,
                                                            sticky="w",
                                                            padx=4,
                                                            pady=4)
        Radiobutton(frame_position,
                    text=_("Always above"),
                    value="above",
                    variable=self.position).grid(row=1, column=0, padx=4)
        Radiobutton(frame_position,
                    text=_("Always below"),
                    value="below",
                    variable=self.position).grid(row=1, column=1, padx=4)
        Radiobutton(frame_position,
                    text=_("Normal"),
                    value="normal",
                    variable=self.position).grid(row=1, column=2, padx=4)
        # ---- titlebar
        self.titlebar_disposition = StringVar(
            self, CONFIG.get("General", "buttons_position"))
        self.title_var = StringVar(
            self)  # to add date if date_in_title is true
        font_title = "%s %s" % (CONFIG.get("Font", "title_family").replace(
            " ", "\ "), CONFIG.get("Font", "title_size"))
        style = CONFIG.get("Font", "title_style").split(",")
        if style:
            font_title += " "
            font_title += " ".join(style)

        frame_titlebar = Frame(general_settings)
        frame_titlebar.columnconfigure(1, weight=1)
        frame_titlebar.columnconfigure(3, weight=1)
        Label(frame_titlebar,
              text=_("Title bar disposition")).grid(row=0,
                                                    columnspan=4,
                                                    sticky="w",
                                                    padx=4,
                                                    pady=4)
        Radiobutton(frame_titlebar,
                    value="right",
                    variable=self.titlebar_disposition).grid(row=1,
                                                             column=0,
                                                             padx=4)
        right = Frame(frame_titlebar, style="titlebar.TFrame")
        right.grid(row=1, column=1, sticky="ew", padx=4)

        def select_right(event):
            self.titlebar_disposition.set("right")

        Label(right,
              textvariable=self.title_var,
              style="titlebar.TLabel",
              anchor="center",
              font=font_title).pack(side="left", fill="x", expand=True)
        Label(right, image="img_close",
              style="titlebar.TLabel").pack(side="right")
        Label(right, image="img_roll",
              style="titlebar.TLabel").pack(side="right")
        for ch in right.children.values():
            ch.bind("<Button-1>", select_right)
        Radiobutton(frame_titlebar,
                    value="left",
                    variable=self.titlebar_disposition).grid(row=1, column=2)
        left = Frame(frame_titlebar, style="titlebar.TFrame")
        left.grid(row=1, column=3, sticky="ew")

        def select_left(event):
            self.titlebar_disposition.set("left")

        Label(left, image="img_close",
              style="titlebar.TLabel").pack(side="left")
        Label(left, image="img_roll",
              style="titlebar.TLabel").pack(side="left")
        Label(left,
              textvariable=self.title_var,
              style="titlebar.TLabel",
              anchor="center",
              font=font_title).pack(side="right", fill="x", expand=True)
        for ch in left.children.values():
            ch.bind("<Button-1>", select_left)

        self.date_in_title = BooleanVar(
            self, CONFIG.getboolean('General', 'date_in_title', fallback=True))
        date_in_title = Checkbutton(frame_titlebar,
                                    variable=self.date_in_title,
                                    text=_('Display creation date in title'),
                                    command=self.toggle_date)
        date_in_title.grid(row=2, columnspan=4, sticky='w', pady=4, padx=4)
        self.toggle_date()
        # ---- placement
        lang_frame.grid(sticky="w")
        Separator(general_settings, orient="horizontal").grid(sticky="ew",
                                                              pady=10)
        gui_frame.grid(sticky="w")
        Separator(general_settings, orient="horizontal").grid(sticky="ew",
                                                              pady=10)
        # opacity_frame.grid(sticky='w')
        self.opacity.grid(sticky='w', padx=4)
        Separator(general_settings, orient="horizontal").grid(sticky="ew",
                                                              pady=10)
        frame_position.grid(sticky="ew")
        Separator(general_settings, orient="horizontal").grid(sticky="ew",
                                                              pady=10)
        frame_titlebar.grid(sticky="ew", pady=4)

        # ---- clean local data
        Separator(general_settings, orient="horizontal").grid(sticky="ew",
                                                              pady=10)
        Button(general_settings,
               text=_('Delete unused local data'),
               command=self.cleanup).grid(padx=4, pady=4, sticky='w')

        # ---- splash supported
        Separator(general_settings, orient="horizontal").grid(sticky="ew",
                                                              pady=10)
        self.splash_support = Checkbutton(
            general_settings,
            text=_("Check this box if the notes disappear when you click"))
        self.splash_support.grid(padx=4, pady=4, sticky='w')
        if not CONFIG.getboolean('General', 'splash_supported', fallback=True):
            self.splash_support.state(('selected', '!alternate'))
        else:
            self.splash_support.state(('!selected', '!alternate'))
Example #32
0
    def __init__(self):
        # initialize RED and BLUE fighters
        self.RED = 0
        self.BLUE = 1

        # initialize score and kyonggo variables
        self.redPoints = 0
        self.bluePoints = 0
        self.redKyonggo = 0
        self.blueKyonggo = 0
        self.currentRound = 0
        self.display = None
        self.miniDisplay = None
        self.numRounds = 0
        self.timer = None
        self.isSuddenDeath = False
        self.callNextRound = True
        try:
            # for Python3
            super().__init__()
        except:
            # for Python2
            Frame.__init__(self)

        # set title and default style
        self.master.title("TKD Scoring System")
        # create style
        self.s = Style()
        self.s.configure("TButton", padding=10, font=(None, 20))
        self.s.configure("TCheckbutton", padding=10, font=(None, 20))
        self.s.configure("TOptionMenu", padding=10, font=(None, 20))
        self.pack(fill=BOTH, expand=True)
        # create setup frames, labels, and entries
        # time entry frame
        self.setTimeFrame = Frame(self)
        self.timerLabel = Label(self.setTimeFrame,
                                text="Time:",
                                font=(None, 20))
        self.secondsEntry = Entry(self.setTimeFrame, width=3, font=(None, 20))
        self.colonLabel = Label(self.setTimeFrame, text=":", font=(None, 20))
        self.minuteEntry = Entry(self.setTimeFrame, width=3, font=(None, 20))
        # round entry frame
        self.roundsFrame = Frame(self)
        self.roundsLabel = Label(self.roundsFrame,
                                 text="Number of Rounds:",
                                 font=(None, 20))
        self.roundsEntry = Entry(self.roundsFrame, width=3, font=(None, 20))
        # serial entry frame
        self.serialFrame = Frame(self)
        try:
            self.arduino_ports = ["None"] + [
                p.device for p in serial.tools.list_ports.comports()
            ]
        except:
            # if serial is not installed
            self.arduino_ports = ["None"]
        self.serialEntry = StringVar()
        self.serialEntry.set("None")
        self.serialLabel = Label(self.serialFrame,
                                 text="Serial Input:",
                                 font=(None, 20))
        self.serialCheck = OptionMenu(self.serialFrame, self.serialEntry,
                                      "None", *self.arduino_ports)
        self.createMatchButton = Button(self,
                                        text="Create Match",
                                        style="TButton",
                                        command=self.hideSetup)

        # initialize frames for UI
        # red frame and buttons
        self.redFrame = Frame(self)
        self.redScoreButton = Button(
            self.redFrame,
            text="Red +",
            style="TButton",
            command=lambda: self.incrementPoints(self.RED))
        self.redDeletePoint = Button(
            self.redFrame,
            text="Red -",
            style="TButton",
            command=lambda: self.deductPoints(self.RED))
        self.redKyonggoButton = Button(
            self.redFrame,
            text="Kyonggo +",
            style="TButton",
            command=lambda: self.callKyonggo(self.RED))
        self.redKyonggoDelete = Button(
            self.redFrame,
            text="Kyonggo -",
            style="TButton",
            command=lambda: self.deductKyonggo(self.RED))
        # blue frame and buttons
        self.blueFrame = Frame(self)
        self.blueScoreButton = Button(
            self.blueFrame,
            text="Blue +",
            style="TButton",
            command=lambda: self.incrementPoints(self.BLUE))
        self.blueDeletePoint = Button(
            self.blueFrame,
            text="Blue -",
            style="TButton",
            command=lambda: self.deductPoints(self.BLUE))
        self.blueKyonggoButton = Button(
            self.blueFrame,
            text="Kyonggo +",
            style="TButton",
            command=lambda: self.callKyonggo(self.BLUE))
        self.blueKyonggoDelete = Button(
            self.blueFrame,
            text="Kyonggo -",
            style="TButton",
            command=lambda: self.deductKyonggo(self.BLUE))
        # reset and new match frame and buttons
        self.resetFrame = Frame(self)
        self.startStop = StringVar()
        self.timerStartStop = Button(self.resetFrame,
                                     textvariable=self.startStop,
                                     style="TButton",
                                     command=self.timerPush)
        self.startStop.set("Start Round 1")
        self.newMatch = Button(self.resetFrame,
                               text="New Match",
                               style="TButton",
                               command=self.newMatch)
        self.resetMatch = Button(self.resetFrame,
                                 text="Reset Match",
                                 style="TButton",
                                 command=self.resetMatch)

        self.setup()
    def picture(self, adr):
        """
        This function creates three lables with pictures, first label show
        differences between pictures in next two labels.

        Parameters:
        ----------
        adr: str
            Path to chart.
        """
        adress_1 = self.listOfPaths[adr]
        adress_2 = adress_1.replace(self.directory1, self.directory2)

        file_img1 = Image.open(adress_1)
        try:
            file_img2 = Image.open(adress_2)
        except FileNotFoundError:
            adr = self.listOfPaths[self.i]
            self.addToListbox(adr)
            self.onNoPlot()
            return None

        self.fill_text_fields(adress_1, adress_2)
        diff = ImageChops.difference(file_img1, file_img2)
        diff = diff.resize((600, 600))
        diffjov = ImageTk.PhotoImage(diff)
        label1 = Label(self, image=diffjov)
        label1.image = diffjov
        label1.place(x=10, y=60)

        file_img1 = file_img1.resize((600, 600))
        image_2 = ImageTk.PhotoImage(file_img1)
        label2 = Label(self, image=image_2)
        label2.image = image_2
        label2.place(x=620, y=60)

        file_img2 = file_img2.resize((600, 600))
        image_3 = ImageTk.PhotoImage(file_img2)
        label3 = Label(self, image=image_3)
        label3.image = image_3
        label3.place(x=1230, y=60)
Example #34
0
class GuiKtl(Tk):
    """Handle the graphical interface for ktl2help and most of the logic"""

    def __init__(self, parent):
        """initialize the GuiCore"""
        Tk.__init__(self, parent)
        self.parent = parent
        self._initialize_variables()
        # with open('LOCALIZED_TEXT.json', 'r') as f:
        #     self.LT = json.load(f)
        lines = Path('LOCALIZED_TEXT.json').read_text(encoding='utf-8')
        self.LT = json.loads(lines)
        langs = sorted(list(self.LT.keys()))
        self.INTERFACE_LANGS = langs
        lang = 'en-US'
        self._initialize_main_window_menu(lang)
        self._initialize_main_window_notebook(lang)
        self._initialize_main_window(lang)
        if platform.system() not in ['Windows', 'Linux']:
            # so on f0, the Project tab…
            messagebox.showwarning(
                  'Warning', "Help I've been kidnaped by {platform.system()}!!!")

        self._initialize_f7(lang)  # make keyman files and help docs

        ktl2help_styles = Style()
        ktl2help_styles.configure('lowlight.TButton',
                                  font=('Sans', 8, 'bold'),)
        ktl2help_styles.configure('highlght.TButton',
                                  font=('Sans', 11, 'bold'),
                                  background='white', foreground='#007F00')
        ktl2help_styles.configure('wleft.TRadiobutton',
                                  anchor='w', justify='left')

    def _initialize_variables(self):
        """initialize variables for GuiCore"""
        self.font = font.Font()
        self.script_dir = SCRIPT_DIR
        self.klcfiles = list()

        self.int_var = IntVar()
        self.current_project = StringVar()
        self.currentSrcDir = StringVar()
        self.selected_lang = StringVar()
        self.currentEntry = StringVar()
        self.set_field = StringVar()
        self.spklDir = StringVar()
        self.kmflDir = StringVar()
        self.f7ktl = StringVar()
        self.menubar = Menu(self)
        self.filemenu = Menu(self.menubar)
        self.helpmenu = Menu(self.menubar)

    def _initialize_main_window_menu(self, lang='en-US'):
        """initialize the menubar on the main window"""

        self.option_add('*tearOff', FALSE)
        self.config(menu=self.menubar)
        self.menubar.add_cascade(label=self.LT[lang]['File'],
                                 menu=self.filemenu)
        self.filemenu.add_separator()
        self.filemenu.add_command(label=self.LT[lang]['Exit'],
                                  command=self.quit)

        self.menubar.add_cascade(label=self.LT[lang]['Help'],
                                 menu=self.helpmenu)
        self.helpmenu.add_command(label=self.LT[lang]['Read Me'],
                                  command=self._on_read_me)
        self.helpmenu.add_command(label=self.LT[lang]['About...'],
                                  command=on_copyright)

    def _initialize_main_window_notebook(self, lang):
        """initializes notebook widget on main window"""
        # self.n = Notebook(self, width=1400)
        # notebook
        self.n = Notebook(self, width=1015)
        self.n.grid(column=0, columnspan=7, row=1, padx=5, pady=5, sticky='ew')
        self.grid_rowconfigure(1, weight=1)
        self.grid_columnconfigure(0, weight=1)
        self.n.grid_rowconfigure(0, weight=1)
        self.n.grid_columnconfigure(0, weight=1)
        self.f7 = Frame(self.n)
        self.n.add(self.f7, text=self.LT[lang]['Make help files'])

    def _initialize_main_window(self, lang='en-US'):
        """ initialize the main window"""

        self.f_1 = Frame(self)
        self.f_1.grid(column=0, row=0, sticky='news')
        self.f_1.grid_rowconfigure(0, weight=0)
        self.f_1.grid_columnconfigure(0, weight=0)
        # in top of window
        self.lblGuiLanguage = Label(self.f_1,
                                    text=self.LT[lang]['0InterfaceLanguage>'])
        self.lblGuiLanguage.grid(column=4, row=0, padx=5, pady=5, sticky='e')
        self.lblGuiLanguage['justify'] = 'right'
        # Create and fill the dropdown ComboBox.
        self.ddnGuiLanguage = Combobox(self.f_1,
                                       textvariable=self.selected_lang)
        self.ddnGuiLanguage.grid(column=5, columnspan=1, row=0,
                                 padx=5, pady=5, sticky='w')
        self.ddnGuiLanguage['text'] = 'Interface language:'
        self.ddnGuiLanguage['justify'] = 'left'
        self.ddnGuiLanguage.bind('<<ComboboxSelected>>', self._change_lang)
#        self.ddnGuiLanguage['values'] = [self.INTERFACE_LANGS['langs'][k] \
#                                for k in sorted(self.INTERFACE_LANGS['langs'])]
        self.ddnGuiLanguage['values'] = self.INTERFACE_LANGS
        self.ddnGuiLanguage.set(self.INTERFACE_LANGS[0])

#        self.lblMode = Label(self.f_1, text=self.LT[lang]['Mode>'])
#        self.lblMode.grid(column=6, row=0, padx=5, pady=5, sticky='e')

        # assumes tab based interface
        # main frame holds gui interface lange pull down, lists current project,
        # and save settings button

        self.progbar = Progressbar(self, maximum=100, variable=self.int_var)
        self.progbar.grid(column=0, row=6, columnspan=8, padx=5, pady=5,
                          sticky='news')
        self.status = Label(self, text=self.LT[lang]['empty string'],
                            anchor='w', justify='left')
        self.status.grid(column=0, row=7, columnspan=8, padx=5, pady=5,
                         sticky='news')

    def _initialize_f7(self, lang):
        """initialize Make/Remake help files tab from project ktl/kmn/kvks.
           Has text box and browse button to ktl file,
           plus OK - Make/Remake help files, creating any necessary folders.
           All help files created relative to position of ktl file.
           A common file name and location assumed for
           ktl, kmn and kvks files, only the extensions differ."""
        self.lblf7Intro = Label(self.f7,
                                text=self.LT[lang]["f7Intro"],
                                    anchor='w', justify='left')  # , wraplength=600)
        self.lblf7Intro.grid(column=0, row=0,
                                 columnspan=4, padx=5, pady=5, sticky='news')
        # Source Directory -label, entrybox, browse button
        self.lblf7ktl = Label(self.f7,
                              text=self.LT[lang]['f7ktl'],
                              anchor='w', justify='left')
        self.lblf7ktl.grid(column=0, row=1, columnspan=1, padx=5, pady=5,
                           sticky='w')
        self.lblf7ktlfile = Label(self.f7, textvariable=self.f7ktl,
                                  anchor='w', justify='left')
        self.lblf7ktlfile.grid(column=1, row=1, columnspan=2, padx=5, pady=5,
                               sticky='w')
        self.btnf7Browse = Button(self.f7, text="...",
                                  command=self._on_f7_browse,
                                  style='highlight.TButton')
        self.btnf7Browse.grid(column=3, row=1, padx=5, pady=5, sticky='news')
        self.btnf7Browse_ttp = CreateToolTip(self.f7,
                                             self.LT[lang]['f7Browse_ttp'])

        self.btnf7MakeHelp = Button(self.f7,
                                     text=self.LT[lang]["Make help files"],
                                     command=self._on_f7_make_help,
                                     style='highlight.TButton')
        self.btnf7MakeHelp.grid(column=2, row=20, columnspan=2, padx=5, pady=5,
                                                                 sticky='news')

    def _on_f7_browse(self):
        """browse to ktl file and load path into self.f7ktl"""
        lang = self.ddnGuiLanguage.get()
        self.f7ktl.set(filedialog.askopenfilename(
                         initialdir=os.path.expanduser('~/Documents/Keyman Developer/Projects'),
                         title=self.LT[lang]["SelectKTLfile"],
                         filetypes=(('keyman file', '*.keyman-touch-layout'),
                                    ("all files", "*.*"))))

    def _on_f7_make_help(self):
        """makes keyman help files"""
        touch = Touch(Path(self.f7ktl.get()), Path(SCRIPT_DIR), self.LT)
        touch.create_help_for_devices()

    def _on_read_me(self):
        """calls the appropriate 'help' file from the menubar"""

        lang = self.ddnGuiLanguage.get()
        app_dir = get_script_directory()
        # open an HTML file on my own computer
        if lang == 'en-US':
            url = os.path.normpath("file://" + app_dir + "/Read_Me.html")
        elif lang == 'fr-FR':
            url = os.path.normpath("file://" + app_dir + "/Lire_Moi.html")
        elif lang == 'pt-PT':
            # need portugese version, default to eng
            url = os.path.normpath("file://" + app_dir + "/Read_Me.html")
        else:
            messagebox.showwarning('Warning',
f"Error in on_read_me: {lang} is unrecognised lang, defaulting to 'en-US.'")
            url = os.path.normpath("file://" + app_dir + "/Read_Me.html")
        webbrowser.open(url)

    def _change_lang(self, lang):
        '''change lang of labels to interfacelang'''

        self.menubar.entryconfig(0, label=self.LT[lang]['File'])
        self.menubar.entryconfig(1, label=self.LT[lang]['Help'])

        self.filemenu.entryconfig(0,
                                  label=self.LT[lang]['Load project settings'])
        self.filemenu.entryconfig(1, label=self.LT[lang]['Save'])
        self.filemenu.entryconfig(2,
                                  label=self.LT[lang]['Delete project settings'])
        self.filemenu.entryconfig(4, label=self.LT[lang]['Exit'])

        self.helpmenu.entryconfig(0, label=self.LT[lang]['Read Me'])
        self.helpmenu.entryconfig(1, label=self.LT[lang]['About...'])

        self.lblGuiLanguage['text'] = \
                           self.LT[lang]['Interface language>']
        self.lblProject['text'] = self.LT[lang]['Current Project>'] + \
                                               ' ' + self.ddnCurProject.get()
        self.lblMode['text'] = ''.join([self.LT[lang]['Mode>'],
                                        self.LT[lang]["Simple"
                                                      if self.mode.get() == 0
                                                             else "Advanced"]])
        self.lblCurTemplate_ttp['text'] = self.LT[lang]['CurTemplate_ttp']
        self.lblCurTemplate['text'] = self.LT[lang]['UseTemplate>']
        self.btnCreateTemplate['text'] = self.LT[lang]["CreateTemplate"]

        self.btnSavePref['text'] = self.LT[lang]["SavePref"]

        self.boxOptional['text'] = self.LT[lang]["Optional"]
        self.lblInitialDigit['text'] = self.LT[lang]['InitialDigit']

        self.lblIdiot['text'] = self.LT[lang]['IdiotMode']
        self.rdbIdiot['text'] = self.LT[lang]['Simple']
        self.rdbAdvanced['text'] = self.LT[lang]['Advanced']
        self.f0_ttp['text'] = self.LT[lang]['f0_ttp']

        self.lblLatin1['text'] = self.LT[lang]["AddLatin1Example"]
        self.btnF2Next['text'] = self.LT[lang]["Next"]

        self.lblM0['text'] = self.LT[lang]['M0_ttp']
        self.lblM2['text'] = \
                  self.LT[lang]['M2_ttp1' if self.mode.get() == 1
                                                 else 'M2_ttp']
        self.lblArt['text'] = self.LT[lang]["Art_ttp"]
        self.lblCurProject['text'] = self.LT[lang]['Current Project>']
        self.btnBuildOutputTo['text'] = self.LT[lang]['Output to>']
        self.lblTrimTitle['text'] = self.LT[lang]['TrimTitle_ttp']
        self.box0['text'] = self.LT[lang]["and/or"]
        self.box1['text'] = self.LT[lang]['Adjust order of files']
        self.box2['text'] = self.LT[lang]['As needed']
        self.box1M1['text'] = self.LT[lang]['Change indent']
        self.box2M1['text'] = self.LT[lang]['Change order']
        self.labelf1['text'] = self.LT[lang]['labelf1']
    def __init__(self, mainWin, modulesWithNewerFileDates):
        super(DialogPluginManager, self).__init__(mainWin.parent)

        self.ENABLE = _("Enable")
        self.DISABLE = _("Disable")
        self.parent = mainWin.parent
        self.cntlr = mainWin

        # copy plugins for temporary display
        self.pluginConfig = PluginManager.pluginConfig
        self.pluginConfigChanged = False
        self.uiClassMethodsChanged = False
        self.modelClassesChanged = False
        self.customTransformsChanged = False
        self.disclosureSystemTypesChanged = False
        self.hostSystemFeaturesChanged = False
        self.modulesWithNewerFileDates = modulesWithNewerFileDates

        parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)",
                                  self.parent.geometry())
        dialogX = int(parentGeometry.group(3))
        dialogY = int(parentGeometry.group(4))

        self.title(_("Plug-in Manager"))
        frame = Frame(self)

        # left button frame
        buttonFrame = Frame(frame, width=40)
        buttonFrame.columnconfigure(0, weight=1)
        addLabel = Label(buttonFrame,
                         text=_("Find plug-in modules:"),
                         wraplength=60,
                         justify="center")
        addSelectLocalButton = Button(buttonFrame,
                                      text=_("Select"),
                                      command=self.selectLocally)
        ToolTip(
            addSelectLocalButton,
            text=_(
                "Select python module files from the local plugin directory."),
            wraplength=240)
        addBrowseLocalButton = Button(buttonFrame,
                                      text=_("Browse"),
                                      command=self.browseLocally)
        ToolTip(
            addBrowseLocalButton,
            text=
            _("File chooser allows browsing and selecting python module files to add (or reload) plug-ins, from the local file system."
              ),
            wraplength=240)
        addWebButton = Button(buttonFrame,
                              text=_("On Web"),
                              command=self.findOnWeb)
        ToolTip(
            addWebButton,
            text=
            _("Dialog to enter URL full path to load (or reload) plug-ins, from the web or local file system."
              ),
            wraplength=240)
        addLabel.grid(row=0, column=0, pady=4)
        addSelectLocalButton.grid(row=1, column=0, pady=4)
        addBrowseLocalButton.grid(row=2, column=0, pady=4)
        addWebButton.grid(row=3, column=0, pady=4)
        buttonFrame.grid(row=0,
                         column=0,
                         rowspan=3,
                         sticky=(N, S, W),
                         padx=3,
                         pady=3)

        # right tree frame (plugins already known to arelle)
        modulesFrame = Frame(frame, width=720)
        vScrollbar = Scrollbar(modulesFrame, orient=VERTICAL)
        hScrollbar = Scrollbar(modulesFrame, orient=HORIZONTAL)
        self.modulesView = Treeview(modulesFrame,
                                    xscrollcommand=hScrollbar.set,
                                    yscrollcommand=vScrollbar.set,
                                    height=7)
        self.modulesView.grid(row=0, column=0, sticky=(N, S, E, W))
        self.modulesView.bind('<<TreeviewSelect>>', self.moduleSelect)
        hScrollbar["command"] = self.modulesView.xview
        hScrollbar.grid(row=1, column=0, sticky=(E, W))
        vScrollbar["command"] = self.modulesView.yview
        vScrollbar.grid(row=0, column=1, sticky=(N, S))
        modulesFrame.columnconfigure(0, weight=1)
        modulesFrame.rowconfigure(0, weight=1)
        modulesFrame.grid(row=0,
                          column=1,
                          columnspan=4,
                          sticky=(N, S, E, W),
                          padx=3,
                          pady=3)
        self.modulesView.focus_set()

        self.modulesView.column("#0", width=120, anchor="w")
        self.modulesView.heading("#0", text=_("Name"))
        self.modulesView["columns"] = ("author", "ver", "status", "date",
                                       "update", "descr", "license")
        self.modulesView.column("author", width=100, anchor="w", stretch=False)
        self.modulesView.heading("author", text=_("Author"))
        self.modulesView.column("ver", width=60, anchor="w", stretch=False)
        self.modulesView.heading("ver", text=_("Version"))
        self.modulesView.column("status", width=50, anchor="w", stretch=False)
        self.modulesView.heading("status", text=_("Status"))
        self.modulesView.column("date", width=70, anchor="w", stretch=False)
        self.modulesView.heading("date", text=_("File Date"))
        self.modulesView.column("update", width=50, anchor="w", stretch=False)
        self.modulesView.heading("update", text=_("Update"))
        self.modulesView.column("descr", width=200, anchor="w", stretch=False)
        self.modulesView.heading("descr", text=_("Description"))
        self.modulesView.column("license", width=70, anchor="w", stretch=False)
        self.modulesView.heading("license", text=_("License"))

        classesFrame = Frame(frame)
        vScrollbar = Scrollbar(classesFrame, orient=VERTICAL)
        hScrollbar = Scrollbar(classesFrame, orient=HORIZONTAL)
        self.classesView = Treeview(classesFrame,
                                    xscrollcommand=hScrollbar.set,
                                    yscrollcommand=vScrollbar.set,
                                    height=5)
        self.classesView.grid(row=0, column=0, sticky=(N, S, E, W))
        hScrollbar["command"] = self.classesView.xview
        hScrollbar.grid(row=1, column=0, sticky=(E, W))
        vScrollbar["command"] = self.classesView.yview
        vScrollbar.grid(row=0, column=1, sticky=(N, S))
        classesFrame.columnconfigure(0, weight=1)
        classesFrame.rowconfigure(0, weight=1)
        classesFrame.grid(row=1,
                          column=1,
                          columnspan=4,
                          sticky=(N, S, E, W),
                          padx=3,
                          pady=3)
        self.classesView.focus_set()

        self.classesView.column("#0", width=200, anchor="w")
        self.classesView.heading("#0", text=_("Class"))
        self.classesView["columns"] = ("modules", )
        self.classesView.column("modules",
                                width=500,
                                anchor="w",
                                stretch=False)
        self.classesView.heading("modules", text=_("Modules"))

        # bottom frame module info details
        moduleInfoFrame = Frame(frame, width=700)
        moduleInfoFrame.columnconfigure(1, weight=1)

        self.moduleNameLabel = Label(moduleInfoFrame,
                                     wraplength=600,
                                     justify="left",
                                     font=font.Font(family='Helvetica',
                                                    size=12,
                                                    weight='bold'))
        self.moduleNameLabel.grid(row=0, column=0, columnspan=4, sticky=W)
        self.moduleAuthorHdr = Label(moduleInfoFrame,
                                     text=_("author:"),
                                     state=DISABLED)
        self.moduleAuthorHdr.grid(row=1, column=0, sticky=W)
        self.moduleAuthorLabel = Label(moduleInfoFrame,
                                       wraplength=600,
                                       justify="left")
        self.moduleAuthorLabel.grid(row=1, column=1, columnspan=3, sticky=W)
        self.moduleDescrHdr = Label(moduleInfoFrame,
                                    text=_("description:"),
                                    state=DISABLED)
        self.moduleDescrHdr.grid(row=2, column=0, sticky=W)
        self.moduleDescrLabel = Label(moduleInfoFrame,
                                      wraplength=600,
                                      justify="left")
        self.moduleDescrLabel.grid(row=2, column=1, columnspan=3, sticky=W)
        self.moduleClassesHdr = Label(moduleInfoFrame,
                                      text=_("classes:"),
                                      state=DISABLED)
        self.moduleClassesHdr.grid(row=3, column=0, sticky=W)
        self.moduleClassesLabel = Label(moduleInfoFrame,
                                        wraplength=600,
                                        justify="left")
        self.moduleClassesLabel.grid(row=3, column=1, columnspan=3, sticky=W)
        ToolTip(self.moduleClassesLabel,
                text=_("List of classes that this plug-in handles."),
                wraplength=240)
        self.moduleVersionHdr = Label(moduleInfoFrame,
                                      text=_("Version:"),
                                      state=DISABLED)
        self.moduleVersionHdr.grid(row=4, column=0, sticky=W)
        self.moduleVersionLabel = Label(moduleInfoFrame,
                                        wraplength=600,
                                        justify="left")
        self.moduleVersionLabel.grid(row=4, column=1, columnspan=3, sticky=W)
        ToolTip(self.moduleVersionLabel,
                text=_("Version of plug-in module."),
                wraplength=240)
        self.moduleUrlHdr = Label(moduleInfoFrame,
                                  text=_("URL:"),
                                  state=DISABLED)
        self.moduleUrlHdr.grid(row=5, column=0, sticky=W)
        self.moduleUrlLabel = Label(moduleInfoFrame,
                                    wraplength=600,
                                    justify="left")
        self.moduleUrlLabel.grid(row=5, column=1, columnspan=3, sticky=W)
        ToolTip(
            self.moduleUrlLabel,
            text=_(
                "URL of plug-in module (local file path or web loaded file)."),
            wraplength=240)
        self.moduleDateHdr = Label(moduleInfoFrame,
                                   text=_("date:"),
                                   state=DISABLED)
        self.moduleDateHdr.grid(row=6, column=0, sticky=W)
        self.moduleDateLabel = Label(moduleInfoFrame,
                                     wraplength=600,
                                     justify="left")
        self.moduleDateLabel.grid(row=6, column=1, columnspan=3, sticky=W)
        ToolTip(
            self.moduleDateLabel,
            text=
            _("Date of currently loaded module file (with parenthetical node when an update is available)."
              ),
            wraplength=240)
        self.moduleLicenseHdr = Label(moduleInfoFrame,
                                      text=_("license:"),
                                      state=DISABLED)
        self.moduleLicenseHdr.grid(row=7, column=0, sticky=W)
        self.moduleLicenseLabel = Label(moduleInfoFrame,
                                        wraplength=600,
                                        justify="left")
        self.moduleLicenseLabel.grid(row=7, column=1, columnspan=3, sticky=W)
        self.moduleImportsHdr = Label(moduleInfoFrame,
                                      text=_("imports:"),
                                      state=DISABLED)
        self.moduleImportsHdr.grid(row=8, column=0, sticky=W)
        self.moduleImportsLabel = Label(moduleInfoFrame,
                                        wraplength=600,
                                        justify="left")
        self.moduleImportsLabel.grid(row=8, column=1, columnspan=3, sticky=W)
        self.moduleEnableButton = Button(moduleInfoFrame,
                                         text=self.ENABLE,
                                         state=DISABLED,
                                         command=self.moduleEnable)
        ToolTip(self.moduleEnableButton,
                text=_("Enable/disable plug in."),
                wraplength=240)
        self.moduleEnableButton.grid(row=9, column=1, sticky=E)
        self.moduleReloadButton = Button(moduleInfoFrame,
                                         text=_("Reload"),
                                         state=DISABLED,
                                         command=self.moduleReload)
        ToolTip(self.moduleReloadButton,
                text=_("Reload/update plug in."),
                wraplength=240)
        self.moduleReloadButton.grid(row=9, column=2, sticky=E)
        self.moduleRemoveButton = Button(moduleInfoFrame,
                                         text=_("Remove"),
                                         state=DISABLED,
                                         command=self.moduleRemove)
        ToolTip(
            self.moduleRemoveButton,
            text=
            _("Remove plug in from plug in table (does not erase the plug in's file)."
              ),
            wraplength=240)
        self.moduleRemoveButton.grid(row=9, column=3, sticky=E)
        moduleInfoFrame.grid(row=2,
                             column=0,
                             columnspan=5,
                             sticky=(N, S, E, W),
                             padx=3,
                             pady=3)
        moduleInfoFrame.config(borderwidth=4, relief="groove")

        okButton = Button(frame, text=_("Close"), command=self.ok)
        ToolTip(okButton,
                text=_("Accept and changes (if any) and close dialog."),
                wraplength=240)
        cancelButton = Button(frame, text=_("Cancel"), command=self.close)
        ToolTip(cancelButton,
                text=_("Cancel changes (if any) and close dialog."),
                wraplength=240)
        okButton.grid(row=3, column=3, sticky=(S, E), pady=3)
        cancelButton.grid(row=3, column=4, sticky=(S, E), pady=3, padx=3)

        enableDisableFrame = Frame(frame)
        enableDisableFrame.grid(row=3, column=1, sticky=(S, W), pady=3)
        enableAllButton = Button(enableDisableFrame,
                                 text=_("Enable All"),
                                 command=self.enableAll)
        ToolTip(enableAllButton,
                text=_("Enable all plug ins."),
                wraplength=240)
        disableAllButton = Button(enableDisableFrame,
                                  text=_("Disable All"),
                                  command=self.disableAll)
        ToolTip(disableAllButton,
                text=_("Disable all plug ins."),
                wraplength=240)
        enableAllButton.grid(row=1, column=1)
        disableAllButton.grid(row=1, column=2)

        self.loadTreeViews()

        self.geometry("+{0}+{1}".format(dialogX + 50, dialogY + 100))
        frame.grid(row=0, column=0, sticky=(N, S, E, W))
        frame.columnconfigure(0, weight=0)
        frame.columnconfigure(1, weight=1)
        frame.rowconfigure(0, weight=1)
        window = self.winfo_toplevel()
        window.columnconfigure(0, weight=1)
        window.rowconfigure(0, weight=1)

        self.bind("<Return>", self.ok)
        self.bind("<Escape>", self.close)

        self.protocol("WM_DELETE_WINDOW", self.close)
        self.grab_set()
        self.wait_window(self)
class XlsTab(ViewBlock):
    def __init__(self, basis):
        super().__init__(basis)
        self.xlsData = None
        self.frmTab.grid_rowconfigure(2, weight=1)
        self.frmTab.grid_columnconfigure(1, weight=1)

        self.frmFile = Frame(self.frmTab)
        self.btnOpen = Button(self.frmFile,
                              command=self.clickBtnOpen,
                              text='Открыть')
        self.lblPath = Label(self.frmFile, text='')

        self.frmOptions = Frame(self.frmTab)
        self.frmOptions.grid_columnconfigure(0, weight=1)

        self.argOpt_wd6 = {'master': self.frmOptions, 'width': 6}
        self.argOptionCell = dict(self.argOpt_wd6, **self.vld.vldCell)
        self.argOptionDate = dict(self.argOpt_wd6, **self.vld.vldDate)
        self.argOptionInteger = dict(self.argOpt_wd6, **self.vld.vldInt)
        self.argOptionReadonly = dict(self.argOpt_wd6, **{'state': 'readonly'})

        self.lblSheet = Label(self.frmOptions, text='Лист Excel №: ')
        self.lblCellRange = Label(self.frmOptions, text='Диапазон ячеек: ')
        self.cmbSheet = Combobox(**self.argOptionReadonly)
        self.entCellStart = Entry(**self.argOptionCell)
        self.entCellFinish = Entry(**self.argOptionCell)

        self.lblSheet.grid(row=0, **self.grd.cl0_pdSt_stW)
        self.cmbSheet.grid(row=0, **self.grd.cl1_sp2_pdSt_stWE)
        self.lblCellRange.grid(row=1, **self.grd.cl0_pdSt_stW)
        self.entCellStart.grid(row=1, sticky='w, e', **self.grd.cl1_pdSt)
        self.entCellFinish.grid(row=1,
                                column=2,
                                sticky='w, e',
                                **self.grd.pdSt)

        self.cmbSheet.bind('<<ComboboxSelected>>', self.selectData)
        self.entCellStart.bind('<KeyRelease>', self.selectData)
        self.entCellFinish.bind('<KeyRelease>', self.selectData)

        self.frmProgress = Frame(self.frmTab)
        self.frmProgress.grid_columnconfigure(0, weight=1)
        self.lblProgress = Label(self.frmProgress)
        self.prgProgress = Progressbar(self.frmProgress, mode='determinate')
        self.lblProgress.grid(row=0, column=0, padx=5, pady=0, sticky='w, e')
        self.prgProgress.grid(row=1, column=0, padx=5, pady=0, sticky='w, e')

        self.frmView.grid_propagate(False)
        self.frmFile.grid(row=0, columnspan=2, **self.grd.cl0_pdSt_stW)
        self.frmOptions.grid(row=1, sticky='n, e, s, w', **self.grd.cl0_pdSt)
        self.frmView.grid(row=1,
                          sticky='n, e, s, w',
                          rowspan=2,
                          **self.grd.cl1_pdSt)
        self.frmProgress.grid(row=3,
                              sticky='w, e',
                              columnspan=2,
                              **self.grd.cl0_pdSt)

    def getScope(self):
        self.resetOptions()
        self.resetView()
        lastRow = len(self.xlsData[self.sheetID]) - 1
        lastCol = len(self.xlsData[self.sheetID][0]) - 1
        cellStart = self.entCellStart.get()
        cellFinish = self.entCellFinish.get()
        self.colStart, self.rowStart = self.getCellID(cellStart)
        self.colFinish, self.rowFinish = self.getCellID(cellFinish)
        if self.rowStart > self.rowFinish:
            self.rowStart, self.rowFinish = self.rowFinish, self.rowStart
        if self.colStart > self.colFinish:
            self.colStart, self.colFinish = self.colFinish, self.colStart
        if self.colFinish > lastCol:
            self.colFinish = lastCol
        if self.rowFinish > lastRow:
            self.rowFinish = lastRow

    def clickBtnOpen(self):
        self.path = askopenfilename(filetypes=[('Microsoft Excel 97/2003',
                                                '.xls')])
        if self.path:
            self.lblPath['text'] = self.path.split('/').pop()
            self.openFile()

    def getColID(self, string):
        string, strSymbols = string.lower(), 'abcdefghijklmnopqrstuvwxyz'
        lenSymbols, number = len(strSymbols), -1
        while string != '':
            lenString = len(string)
            if lenString - 1:
                order = (lenString - 1) * lenSymbols
            else:
                order = 1
            for index in range(lenSymbols):
                if string[0] == strSymbols[index]:
                    number += (index + 1) * order
            string = string[1:]
        return (number)

    def getCellID(self, string):
        try:
            colID = self.getColID(findall('([A-z]+)', string)[0])
            rowID = int(findall('(\d+)', string)[0]) - 1
        except IndexError:
            colID, rowID = 0, 0
        return (colID, rowID)

    def openFile(self):
        self.entCellStart.delete(0, END)
        self.entCellFinish.delete(0, END)
        book = open_workbook(filename=self.path, encoding_override='cp1251')
        self.cmbSheet['values'] = [(sheetID + 1)
                                   for sheetID in range(book.nsheets)]
        sheets = [
            book.sheet_by_index(sheetID) for sheetID in range(book.nsheets)
        ]
        self.xlsData = []
        for sheetID, sheet in enumerate(sheets):
            self.xlsData.append([])
            for colID in range(sheet.nrows):
                self.xlsData[sheetID].append(sheet.row_values(colID))
        if self.cmbSheet['values']:
            self.cmbSheet.set(self.cmbSheet['values'][0])
            if sheets[0].nrows > 0 and sheets[0].ncols > 0:
                self.entCellStart.insert(0, 'A1')
                self.entCellFinish.insert(
                    0, cellname(sheets[0].nrows - 1, sheets[0].ncols - 1))
        book, sheets = None, None
        collect()
        self.selectData()

    def closeFile(self):
        self.xlsData = None
        self.lblPath['text'] = ''
        self.cmbSheet.set('')
        self.cmbSheet['values'] = []
        self.resetOptions()
        self.resetView()

    def resetOptions(self):
        pass

    def resetView(self):
        pass

    def progress(self, string, index, strLen):
        self.lblProgress['text'] = '%s%s%s%s%s%s' % (
            string, '. Обработано ', str(index), ' из ', strLen, '.')
        self.prgProgress['value'] = index
        self.tk.update()
class PriceMasterExporter(Exporter):
    def __init__(self, main):
        super().__init__(main)
        self.toplevel.title('Создать шаблон базы данных прайс-мастера')
        self.db = main.db
        lblProvider = Label(self.frmFields, text='Выберите поставщика')
        self.cmbProvider = Searchbox(
            master=self.frmFields,
            postcommand=self.update_provider_list,
            source = [d['name'] for d in self.db.data['provider_list']],
            width=32)
        self.lblHint = Label(self.frmFields)
        lblProvider.grid(row=0, **self.grd.cl1_pdSt)
        self.cmbProvider.grid(row=1, **self.grd.cl1_pdSt)
        self.lblHint.grid(row=2, **self.grd.cl1_pdSt)
        self.okButton['text'] = 'Сохранить как'
        self.okButton['command'] = self.saveFile
        hintA = 'Поле поставщик — раскрывающийся список с вариантами выбора и встроенным поиском.'
        hintB = 'Клавиши ↑, ↓ — раскрыть список и перемещаться по вариантам, Esc — скрыть, Enter — выбрать.'
        hintC = 'Чтобы вернуть все варианты — очистите соответствующее поле ввода.'
        self.lblHint['text'] = '\n%s\n\n%s\n\n%s' % (hintA, hintB, hintC)
        self.toplevel.bind('<Configure>', self.hint_resize)
    
    def hint_resize(self, event):
        self.lblHint['wraplength'] = self.toplevel.winfo_reqwidth() - 8

    def update_provider_list(self, event=None):
        values = [d['name'] for d in self.db.data['provider_list']]
        self.cmbProvider.source = values
        self.cmbProvider.filter_values()

    def clear(self):
        self.cmbProvider.set('')
        self.cmbProvider.delete(0, END)

    def fillAndShow(self):
        self.clear()
        self.show()

    def saveFile(self):

        data = self.db.data.copy()
        data['provider'] = None
        data['price_list'] = []
        del(data['provider_list'])
        prvName = self.trn.getNameSting(self.cmbProvider.get())

        path = asksaveasfilename(
            defaultextension='.pmt',
            initialfile=prvName+'.pmt',
            filetypes=[('Шаблон базы данных прайс-мастера', '.pmt')],
            parent=self.toplevel)
        
        if prvName and path:
            for record in self.db.data['provider_list']:
                if prvName == record['name']:
                    data['provider'] = record
                    break
            with open(path, 'wb') as filePickle:
                dumpPickle(data, filePickle, protocol=4)
        self.hide()
            
Example #38
0
    def initUI(self):
        # self.master.title("Crypter")
        # self.pack(fill=BOTH, expand=True)

        # self.set_menubar()
        # sidebar
        self.set_sidebar()

        # Add next frame
        frame1 = Frame(self.root)
        frame1.pack(fill=X)

        lbl1 = tk.Label(frame1, text="Location ", width=10)
        lbl1.pack(side=LEFT, padx=5, pady=5)

        self.entry1 = Entry(frame1, textvariable=self.filename)
        self.entry1.pack(fill=X, padx=5, pady=5)

        # btn_browse = tk.Button(frame1, text='Browse', fg='red', command=self.browse_dir)
        # btn_browse.pack(padx=5, pady=5, side=tk.RIGHT)

        # monitor frame
        frame2 = Frame(self.root)
        frame2.pack(fill=X)

        password = Label(frame2, text="Password", width=10)
        password.pack(side=LEFT, padx=5, pady=5)

        self.password_entry = Entry(frame2, textvariable=self.password_txt)
        self.password_entry.pack(side=LEFT, padx=5, pady=5, fill=X)

        self.algorithm_select = tk.ttk.Combobox(
            frame2, width=10, textvariable=self.selected_algorithm)
        self.selected_algorithm.set(
            self.Encryption_Algorithms[1])  # default value
        self.algorithm_select['values'] = tuple(self.Encryption_Algorithms)
        # combo.grid(column=1, row=0)
        self.algorithm_select.pack(padx=5, pady=5, side=tk.LEFT)
        #
        # mode = tk.Label(frame2, text='Mode', fg='blue')
        # mode.pack(padx=5, pady=5, side=tk.LEFT)
        #
        # # the constructor syntax is:
        # # OptionMenu(master, variable, *values)
        #
        # option_menu = tk.ttk.OptionMenu(frame2, self.selected_mode, self.modes[0], *self.modes)
        # option_menu.pack(padx=5, pady=5, side=tk.LEFT)
        #
        # btn_run_cryption = tk.Button(frame2, text='Run', fg='red', command=self.run_cryption)
        # btn_run_cryption.pack(padx=0, pady=5, side=tk.LEFT)

        frame_in_out_data = tk.Frame(self.root)
        frame_in_out_data.pack(fill=BOTH, expand=True)

        frame_in_data = tk.Frame(frame_in_out_data)
        frame_in_data.pack(fill=tk.Y, expand=True, side=tk.LEFT)
        lbl3 = Label(frame_in_data,
                     text="Input",
                     width=6,
                     font=('Arial', 12, 'bold'))
        lbl3.pack(side=tk.TOP, anchor=N, padx=5, pady=5)

        self.txt_in = tk.Text(frame_in_data, width=50)
        scra = tk.Scrollbar(frame_in_data,
                            orient=tk.VERTICAL,
                            command=self.txt_in.yview)
        self.txt_in.config(yscrollcommand=scra.set,
                           font=('Arial', 12, 'normal'))
        self.txt_in.pack(pady=5, padx=5, expand=True, side=tk.LEFT)

        frame_out_data = tk.Frame(frame_in_out_data)
        frame_out_data.pack(fill=tk.Y, expand=True, side=tk.RIGHT)
        lbl3 = Label(frame_out_data,
                     text="Output",
                     width=6,
                     font=('Arial', 12, 'bold'))
        lbl3.pack(side=tk.TOP, anchor=N, padx=5, pady=5)

        self.txt_out = tk.Text(frame_out_data, width=50)
        scrb = tk.Scrollbar(frame_out_data,
                            orient=tk.VERTICAL,
                            command=self.txt_in.yview)
        self.txt_out.config(yscrollcommand=scrb.set,
                            font=('Arial', 12, 'normal'))
        self.txt_out.pack(pady=5, padx=5, expand=True, side=tk.RIGHT)

        # btn_decrypt = tk.Button(frame_in_out_data, text='Save', fg='red', command=browse_file)
        # btn_decrypt.pack(padx=5, pady=5, side=tk.LEFT)

        pass
Example #39
0
class Progression(Frame):
    """Class to display the progress in filling the puzzle."""
    def __init__(self, master, number, **kwargs):
        kwargs.setdefault('width', 34)
        kwargs.setdefault('height', 34)
        kwargs.setdefault('style', 'case.TFrame')
        Frame.__init__(self, master, **kwargs)
        self.grid_propagate(False)
        self.rowconfigure(0, weight=1)
        self.columnconfigure(0, weight=1)

        self.number = number
        self._nb = 0

        self.label_number = Label(self,
                                  style='case.TLabel',
                                  text=str(number),
                                  font='Arial 16')
        self.label_nb = Label(self,
                              style='case.TLabel',
                              text='0',
                              font='Arial 9')
        self.label_number.grid(row=0, column=0, sticky='e', padx=0)
        self.label_nb.grid(row=0, column=1, sticky='n')

    @property
    def nb(self):
        return self._nb

    @nb.setter
    def nb(self, value):
        self._nb = value
        self.label_nb.configure(text=str(self._nb))

        if self._nb < 9:
            self.configure(style='case.TFrame')
            self.label_number.configure(style='case.TLabel')
            self.label_nb.configure(style='case.TLabel')
        elif self._nb == 9:
            self.configure(style='case_init.TFrame')
            self.label_number.configure(style='case_init.TLabel')
            self.label_nb.configure(style='case_init.TLabel')
        else:
            self.configure(style='erreur.TFrame')
            self.label_number.configure(style='erreur.TLabel')
            self.label_nb.configure(style='erreur.TLabel')
Example #40
0
    def __init__(self, param):
        super(ProjectPage, self).__init__(param)
        self.param = param

        s = Style()
        s.configure('my.TButton', font=('Arial', 16))

        self.widgets = {
            "title":
            Label(self,
                  text=param.main.lang.get_translate("title_project",
                                                     "Project Parameters"),
                  font=("Arial", "18")),
            "name_label":
            Label(self,
                  text=param.main.lang.get_translate("name_project",
                                                     "Name : "),
                  font=("Arial", "14")),
            "name_entry":
            Entry(self),
            "modid_label":
            Label(self,
                  text=param.main.lang.get_translate("modid_project",
                                                     "Mod ID : "),
                  font=("Arial", "14")),
            "modid_entry":
            Entry(self),
            "version_label":
            Label(self,
                  text=param.main.lang.get_translate("version_project",
                                                     "Version : "),
                  font=("Arial", "14")),
            "version_entry":
            Entry(self),
            "url_label":
            Label(self,
                  text=param.main.lang.get_translate("url_project", "URL : "),
                  font=("Arial", "14")),
            "url_entry":
            Entry(self),
            "authors_label":
            Label(self,
                  text=param.main.lang.get_translate("authors_project",
                                                     "Authors : "),
                  font=("Arial", "14")),
            "authors_entry":
            Entry(self),
            "description_label":
            Label(self,
                  text=param.main.lang.get_translate("description_project",
                                                     "Description : "),
                  font=("Arial", "14")),
            "description_entry":
            Entry(self),
            "valide":
            Button(self,
                   text=param.main.lang.get_translate("valide_project",
                                                      "Validate"),
                   style="my.TButton",
                   command=self.validate)
        }

        self.columnconfigure(0, weight=0)
        self.columnconfigure(1, weight=1)

        self.widgets["name_entry"].insert(0, param.main.project.name)
        self.widgets["modid_entry"].insert(0, param.main.project.modid)
        self.widgets["version_entry"].insert(0, param.main.project.version)
        self.widgets["url_entry"].insert(0, param.main.project.url)
        self.widgets["authors_entry"].insert(0, param.main.project.authors)
        self.widgets["description_entry"].insert(
            0, param.main.project.description)

        for k, v in enumerate(self.widgets.values()):
            if k == 0:
                v.grid(row=k,
                       column=0,
                       sticky="NEWS",
                       pady=20,
                       padx=180,
                       columnspan=2)
            elif k in (2, 4, 6, 8, 10, 12):
                v.grid(row=k - 1, column=1, sticky="NESW", pady=10, padx=30)
            elif k == len(self.widgets.keys()) - 1:
                v.grid(row=k,
                       column=0,
                       sticky="NEWS",
                       pady=20,
                       padx=20,
                       columnspan=2)
            else:
                v.grid(row=k, column=0, sticky="NEWS", pady=10, padx=30)
Example #41
0
def create_label(master, row, col, text, pady=0, padx=2):
    '''Takes in master, row number, col number, label display text, and 
       position padding and returns the created labe widgetl'''
    label = Label(master, text=text)
    label.grid(row=row, column=col, pady=pady, padx=padx, sticky=W)
    return label
Example #42
0
    def layout_components(self):
        self.pack(fill=tk.BOTH, expand=False, padx=PADX, pady=PADY)
        error_font = font.Font(family="Ariel", size=8)

        # Variables
        self.username = tk.StringVar()
        self.username.set("")

        self.password = tk.StringVar()
        self.password.set("")

        # Username Row
        user_Frame = Frame(self)
        user_Frame.pack(fill=tk.X)
        user_Label = Label(user_Frame, text="Username:"******"<FocusOut>", self.enable_sign_in)
        self.user_Entry.pack(fill=tk.X, padx=PADX, pady=PADY, expand=True)

        # Password Row
        pass_Frame = Frame(self)
        pass_Frame.pack(fill=tk.X)
        pass_Label = Label(pass_Frame, text="Password:"******"*")
        self.pass_Entry.bind("<FocusOut>", self.enable_sign_in)
        self.pass_Entry.pack(fill=tk.X, padx=PADX, pady=PADY, expand=True)

        # Error Row
        err_Frame = Frame(self)
        err_Frame.pack(fill=tk.X)
        self.err_Label = Label(err_Frame,
                               text="",
                               foreground="red",
                               font=error_font)
        self.err_Label.pack(side=tk.LEFT,
                            anchor="center",
                            expand=True,
                            padx=PADX,
                            pady=PADY)

        # Button Row
        button_Frame = Frame(self)
        button_Frame.pack(fill=tk.X)
        # Cancel Button
        cncl_Button = Button(button_Frame, text="Cancel", command=self.cancel)
        cncl_Button.pack(side=tk.RIGHT, padx=PADX, pady=PADY, expand=False)
        # Sign in Button
        self.sgnn_Button = Button(button_Frame,
                                  text="Sign in",
                                  state="disabled",
                                  command=self._sign_in)
        self.sgnn_Button.pack(side=tk.RIGHT,
                              padx=PADX,
                              pady=PADY,
                              expand=False)

        # Register Row
        register_Frame = Frame(self)
        register_Frame.pack(fill=tk.X)
        register_Button = Button(register_Frame,
                                 text="Register",
                                 command=self._show_register)
        register_Button.pack(side=tk.RIGHT, padx=PADX, pady=PADY, expand=False)
        register_Label = Label(register_Frame,
                               text="Not a Member of ExchangeGram?")
        register_Label.pack(side=tk.RIGHT, padx=PADX, pady=PADY)
Example #43
0
    def _init_font(self):
        font_settings = Frame(self.notebook, padding=4)
        font_settings.columnconfigure(1, weight=1)
        self.notebook.add(font_settings,
                          text=_("Font"),
                          sticky="ewsn",
                          padding=4)

        # ---- title
        title_size = CONFIG.get("Font", "title_size")
        title_family = CONFIG.get("Font", "title_family").replace(" ", "\ ")
        font_title = '{} {}'.format(title_family, title_size)
        style = CONFIG.get("Font", "title_style").split(",")
        if style:
            font_title = font_title + " " + " ".join(style)

        self.title_font = FontFrame(font_settings, font_title, style=True)
        # ---- text
        size = CONFIG.get("Font", "text_size")
        family = CONFIG.get("Font", "text_family").replace(" ", "\ ")

        self.text_font = FontFrame(font_settings, '{} {}'.format(family, size))

        # ---- mono
        mono_fonts = [f for f in set(font.families()) if 'Mono' in f]
        mono_family = CONFIG.get("Font", "mono").replace(" ", "\ ")

        self.mono_font = FontFrame(font_settings,
                                   '{} {}'.format(mono_family, size),
                                   size=False,
                                   font_list=mono_fonts)
        add_trace(
            self.text_font.font_size,
            'write', lambda *args: self.mono_font._config_size(
                self.text_font.font_size, self.mono_font.font))

        # ---- placement
        Label(font_settings, text=_("Title")).grid(row=0,
                                                   column=0,
                                                   padx=4,
                                                   pady=4,
                                                   sticky="nw")
        self.title_font.grid(row=0, column=1, sticky="w", padx=20)
        Separator(font_settings, orient="horizontal").grid(row=1,
                                                           columnspan=2,
                                                           sticky="ew",
                                                           pady=10)
        Label(font_settings, text=_("Text")).grid(row=2,
                                                  column=0,
                                                  padx=4,
                                                  pady=4,
                                                  sticky="nw")
        self.text_font.grid(row=2, column=1, sticky="w", padx=20)
        Separator(font_settings, orient="horizontal").grid(row=3,
                                                           columnspan=2,
                                                           sticky="ew",
                                                           pady=10)
        Label(font_settings, text=_("Mono")).grid(row=4,
                                                  column=0,
                                                  padx=4,
                                                  pady=4,
                                                  sticky="nw")
        self.mono_font.grid(row=4, column=1, sticky="w", padx=20)
Example #44
0
class Control(Frame):
    def __init__(self):
        # initialize RED and BLUE fighters
        self.RED = 0
        self.BLUE = 1

        # initialize score and kyonggo variables
        self.redPoints = 0
        self.bluePoints = 0
        self.redKyonggo = 0
        self.blueKyonggo = 0
        self.currentRound = 0
        self.display = None
        self.miniDisplay = None
        self.numRounds = 0
        self.timer = None
        self.isSuddenDeath = False
        self.callNextRound = True
        try:
            # for Python3
            super().__init__()
        except:
            # for Python2
            Frame.__init__(self)

        # set title and default style
        self.master.title("TKD Scoring System")
        # create style
        self.s = Style()
        self.s.configure("TButton", padding=10, font=(None, 20))
        self.s.configure("TCheckbutton", padding=10, font=(None, 20))
        self.s.configure("TOptionMenu", padding=10, font=(None, 20))
        self.pack(fill=BOTH, expand=True)
        # create setup frames, labels, and entries
        # time entry frame
        self.setTimeFrame = Frame(self)
        self.timerLabel = Label(self.setTimeFrame,
                                text="Time:",
                                font=(None, 20))
        self.secondsEntry = Entry(self.setTimeFrame, width=3, font=(None, 20))
        self.colonLabel = Label(self.setTimeFrame, text=":", font=(None, 20))
        self.minuteEntry = Entry(self.setTimeFrame, width=3, font=(None, 20))
        # round entry frame
        self.roundsFrame = Frame(self)
        self.roundsLabel = Label(self.roundsFrame,
                                 text="Number of Rounds:",
                                 font=(None, 20))
        self.roundsEntry = Entry(self.roundsFrame, width=3, font=(None, 20))
        # serial entry frame
        self.serialFrame = Frame(self)
        try:
            self.arduino_ports = ["None"] + [
                p.device for p in serial.tools.list_ports.comports()
            ]
        except:
            # if serial is not installed
            self.arduino_ports = ["None"]
        self.serialEntry = StringVar()
        self.serialEntry.set("None")
        self.serialLabel = Label(self.serialFrame,
                                 text="Serial Input:",
                                 font=(None, 20))
        self.serialCheck = OptionMenu(self.serialFrame, self.serialEntry,
                                      "None", *self.arduino_ports)
        self.createMatchButton = Button(self,
                                        text="Create Match",
                                        style="TButton",
                                        command=self.hideSetup)

        # initialize frames for UI
        # red frame and buttons
        self.redFrame = Frame(self)
        self.redScoreButton = Button(
            self.redFrame,
            text="Red +",
            style="TButton",
            command=lambda: self.incrementPoints(self.RED))
        self.redDeletePoint = Button(
            self.redFrame,
            text="Red -",
            style="TButton",
            command=lambda: self.deductPoints(self.RED))
        self.redKyonggoButton = Button(
            self.redFrame,
            text="Kyonggo +",
            style="TButton",
            command=lambda: self.callKyonggo(self.RED))
        self.redKyonggoDelete = Button(
            self.redFrame,
            text="Kyonggo -",
            style="TButton",
            command=lambda: self.deductKyonggo(self.RED))
        # blue frame and buttons
        self.blueFrame = Frame(self)
        self.blueScoreButton = Button(
            self.blueFrame,
            text="Blue +",
            style="TButton",
            command=lambda: self.incrementPoints(self.BLUE))
        self.blueDeletePoint = Button(
            self.blueFrame,
            text="Blue -",
            style="TButton",
            command=lambda: self.deductPoints(self.BLUE))
        self.blueKyonggoButton = Button(
            self.blueFrame,
            text="Kyonggo +",
            style="TButton",
            command=lambda: self.callKyonggo(self.BLUE))
        self.blueKyonggoDelete = Button(
            self.blueFrame,
            text="Kyonggo -",
            style="TButton",
            command=lambda: self.deductKyonggo(self.BLUE))
        # reset and new match frame and buttons
        self.resetFrame = Frame(self)
        self.startStop = StringVar()
        self.timerStartStop = Button(self.resetFrame,
                                     textvariable=self.startStop,
                                     style="TButton",
                                     command=self.timerPush)
        self.startStop.set("Start Round 1")
        self.newMatch = Button(self.resetFrame,
                               text="New Match",
                               style="TButton",
                               command=self.newMatch)
        self.resetMatch = Button(self.resetFrame,
                                 text="Reset Match",
                                 style="TButton",
                                 command=self.resetMatch)

        self.setup()

    # displays setup frames
    def setup(self):
        # timer frame
        self.setTimeFrame.pack(fill=X)
        # timer label and entry
        self.timerLabel.pack(side=LEFT, padx=5, pady=5)
        self.secondsEntry.pack(side=RIGHT)
        self.colonLabel.pack(side=RIGHT)
        self.minuteEntry.pack(side=RIGHT)

        # frame for number of rounds
        self.roundsFrame.pack(fill=X)
        # number of rounds label and entry
        self.roundsLabel.pack(side=LEFT, padx=5, pady=5)
        self.roundsEntry.pack(side=RIGHT)

        # frame for serial entry
        self.serialFrame.pack(fill=X, expand=True)
        # serial entry label and checkbox
        self.serialLabel.pack(side=LEFT, padx=5, pady=5)
        self.serialCheck.pack(side=RIGHT)

        # create match button
        self.createMatchButton.pack(side=BOTTOM)

    # hides setup widgets and initalizes timer and number of rounds
    def hideSetup(self):
        # check if minutes, seconds, and round entries are valid
        if len(self.minuteEntry.get()) < 1:
            minutes = 0
        else:
            try:
                minutes = int(self.minuteEntry.get())
            except:
                minutes = 0
        if len(self.secondsEntry.get()) < 1:
            seconds = 0
        else:
            try:
                seconds = int(self.secondsEntry.get()) % 60
                minutes += int(self.secondsEntry.get()) // 60
            except:
                seconds = 0
        if len(self.roundsEntry.get()) < 1:
            numRounds = 0
        else:
            try:
                numRounds = int(self.roundsEntry.get())
            except:
                numRounds = 0
        # set up serial input if checked
        if self.serialEntry.get() != "None":
            self.serialSetup()
        else:
            self.arduino = False
        # only moves on if entries are valid
        if ((minutes != 0) or (seconds != 0)) and (numRounds != 0):
            self.roundLength = [minutes, seconds]
            self.timer = Timer(self.roundLength)
            self.numRounds = numRounds
            self.currentRound = 1
            self.isSuddenDeath = False
            self.roundsFrame.pack_forget()
            self.setTimeFrame.pack_forget()
            self.createMatchButton.pack_forget()
            self.serialFrame.pack_forget()
            self.initUI()

    # set up serial input
    def serialSetup(self):
        try:
            self.arduino = True
            self.serialPort = self.serialEntry.get()
            self.baudRate = 9600
            self.ser = serial.Serial(self.serialPort,
                                     self.baudRate,
                                     timeout=0,
                                     writeTimeout=0)
            self.ser.flushInput()
        except:
            self.arduino = False
            print("Could Not Complete Serial Port Set Up")

    # creates user interface
    def initUI(self):
        # create display
        if self.display == None:
            self.display = Display(self.timer)
            self.display.attributes('-fullscreen', True)
        else:
            self.display.newTimer(self.timer)
            self.display.updateCurrentRound("R1")
        if self.miniDisplay == None:
            self.miniDisplay = miniDisplay(self.timer)
        else:
            self.miniDisplay.newTimer(self.timer)
            self.miniDisplay.updateCurrentRound("R1")

        # red point and kyonggo buttons
        self.redFrame.pack(fill=BOTH, side=LEFT)
        self.redScoreButton.pack(padx=5, pady=5, fill=X)
        self.redDeletePoint.pack(padx=5, pady=5, fill=X)
        self.redKyonggoButton.pack(padx=5, pady=5, fill=X)
        self.redKyonggoDelete.pack(padx=5, pady=5, fill=X)

        # blue point and kyonggo buttons
        self.blueFrame.pack(fill=BOTH, side=RIGHT)
        self.blueScoreButton.pack(padx=5, pady=5, fill=X)
        self.blueDeletePoint.pack(padx=5, pady=5, fill=X)
        self.blueKyonggoButton.pack(padx=5, pady=5, fill=X)
        self.blueKyonggoDelete.pack(padx=5, pady=5, fill=X)

        # timer start/stop button, reset button, and quit button
        self.resetFrame.pack(side=BOTTOM)
        self.startStop.set("Start Round " + str(self.currentRound))
        self.timerStartStop.pack(side=TOP, pady=5)
        self.newMatch.pack(side=LEFT, padx=5)
        self.resetMatch.pack(side=RIGHT, padx=5)

    def timerPush(self):
        # if round is over, reset time give option to start next round
        if self.timer.timeLeft[0] == self.timer.timeLeft[1] == 0:
            self.timer.reset()
            self.startStop.set("Start Round " + str(self.currentRound))
            self.display.updateCurrentRound("R" + str(self.currentRound))
            self.miniDisplay.updateCurrentRound("R" + str(self.currentRound))
            self.updateDisplayTimer()
        # pause timer, give option to unpause
        elif self.timer.isRunning():
            self.timer.stop()
            self.startStop.set("Start")
        # unpause timer, give option to pause
        else:
            if self.arduino:
                self.ser.flushInput()
            self.timer.start()
            if self.arduino:
                self.readSerialInput()
            self.startStop.set("Pause")
            if not self.callNextRound:
                self.callNextRound = True
            self.updateDisplayTimer()

    def resetMatch(self):
        if not self.timer.isRunning():
            self.timer.reset()
            self.redPoints = 0
            self.bluePoints = 0
            self.redKyonggo = 0
            self.blueKyonggo = 0
            self.currentRound = 1
            if self.isSuddenDeath:
                self.isSuddenDeath = False
            self.newMatch.pack_forget()
            self.resetMatch.pack_forget()
            self.timerStartStop.pack(side=TOP, pady=5)
            self.newMatch.pack(side=LEFT, padx=5)
            self.resetMatch.pack(side=RIGHT, padx=5)
            self.startStop.set("Start Round 1")
            self.display.reset(self.timer.getTimeString())
            self.miniDisplay.reset(self.timer.getTimeString())

    def updateDisplayTimer(self):
        if self.timer.isElapsed():
            self.timer.stop()
            if self.callNextRound:
                self.nextRound()
            if self.currentRound < self.numRounds or self.redPoints == self.bluePoints:
                self.display.updateTimer(self.timer.getTimeString())
            self.miniDisplay.updateTimer(self.timer.getTimeString())
        elif self.currentRound > self.numRounds:
            self.suddenDeath()
        else:
            self.display.updateTimer(self.timer.getTimeString())
            self.miniDisplay.updateTimer(self.timer.getTimeString())
            self.after(1000, self.updateDisplayTimer)

    def nextRound(self):
        self.callNextRound = False
        self.currentRound += 1
        if self.currentRound <= self.numRounds:
            self.startStop.set("Reset Timer")
        elif self.redPoints == self.bluePoints:
            self.startStop.set("Sudden Death")
        else:
            self.declareWinner()
            self.timerStartStop.pack_forget()

    def declareWinner(self):
        if self.redPoints > self.bluePoints:
            winner = "RED"
        else:
            winner = "BLUE"
        self.display.updateTimer(winner + " WINS")
        self.display.updateCurrentRound("")

    def suddenDeath(self):
        self.redPoints = 0
        self.display.updateRedPoints(0)
        self.miniDisplay.updateRedPoints(0)
        self.bluePoints = 0
        self.display.updateBluePoints(0)
        self.miniDisplay.updateBluePoints(0)
        self.display.updateTimer("SUDDEN DEATH")
        self.miniDisplay.updateTimer("SUDDEN DEATH")
        self.display.updateCurrentRound("")
        self.miniDisplay.updateCurrentRound("")
        self.isSuddenDeath = True
        if self.arduino:
            self.readSerialInput()
        self.timerStartStop.pack_forget()

    def readSerialInput(self):
        if self.timer.isRunning() or self.isSuddenDeath:
            output = self.ser.readline()
            if len(output) != 0:
                try:
                    fighter = int(output)
                    self.incrementPoints(fighter)
                except:
                    print("Invalid Serial Input")
                self.after(250, self.readSerialInput)
            else:
                self.after(50, self.readSerialInput)

    def incrementPoints(self, fighter):
        if fighter == self.RED:
            self.redPoints += 1
            self.display.updateRedPoints(self.redPoints)
            self.miniDisplay.updateRedPoints(self.redPoints)
        elif fighter == self.BLUE:
            self.bluePoints += 1
            self.display.updateBluePoints(self.bluePoints)
            self.miniDisplay.updateBluePoints(self.bluePoints)
        if self.isSuddenDeath:
            self.declareWinner()

    def deductPoints(self, fighter):
        if fighter == self.RED and self.redPoints > 0:
            self.redPoints -= 1
            self.display.updateRedPoints(self.redPoints)
            self.miniDisplay.updateRedPoints(self.redPoints)
        elif fighter == self.BLUE and self.bluePoints > 0:
            self.bluePoints -= 1
            self.display.updateBluePoints(self.bluePoints)
            self.miniDisplay.updateBluePoints(self.bluePoints)

    def callKyonggo(self, fighter):
        if fighter == self.RED:
            self.redKyonggo += 1
            self.display.updateRedKyonggo("Kyonggo: " + str(self.redKyonggo))
            self.miniDisplay.updateRedKyonggo("Kyonggo: " +
                                              str(self.redKyonggo))
            if self.redKyonggo % 2 == 0:
                self.bluePoints += 1
                self.display.updateBluePoints(self.bluePoints)
                self.miniDisplay.updateBluePoints(self.bluePoints)
        elif fighter == self.BLUE:
            self.blueKyonggo += 1
            self.display.updateBlueKyonggo("Kyonggo: " + str(self.blueKyonggo))
            self.miniDisplay.updateBlueKyonggo("Kyonggo: " +
                                               str(self.blueKyonggo))
            if self.blueKyonggo % 2 == 0:
                self.redPoints -= 1
                self.display.updateRedPoints(self.redPoints)
                self.miniDisplay.updateRedPoints(self.redPoints)

    def deductKyonggo(self, fighter):
        if fighter == self.RED and self.redKyonggo > 0:
            self.redKyonggo -= 1
            self.display.updateRedKyonggo("Kyonggo: " + str(self.redKyonggo))
            self.miniDisplay.updateRedKyonggo("Kyonggo: " +
                                              str(self.redKyonggo))
            if self.redKyonggo % 2 == 1:
                self.redPoints += 1
                self.display.updateRedPoints(self.redPoints)
                self.miniDisplay.updateRedPoints(self.redPoints)
        elif fighter == self.BLUE and self.blueKyonggo > 0:
            self.blueKyonggo -= 1
            self.display.updateBlueKyonggo("Kyonggo: " + str(self.blueKyonggo))
            self.miniDisplay.updateBlueKyonggo("Kyonggo: " +
                                               str(self.blueKyonggo))
            if self.blueKyonggo % 2 == 1:
                self.bluePoints += 1
                self.display.updateBluePoints(self.bluePoints)
                self.miniDisplay.updateBluePoints(self.bluePoints)

    def newMatch(self):
        if not self.timer.isRunning():
            self.redPoints = 0
            self.redKyonggo = 0
            self.bluePoints = 0
            self.blueKyonggo = 0
            self.display.reset("0:00")
            self.miniDisplay.reset("0:00")
            self.hideUI()
            self.setup()

    def hideUI(self):
        self.redFrame.pack_forget()
        self.blueFrame.pack_forget()
        self.resetFrame.pack_forget()
Example #45
0
    def __init__(self, master):
        """Create Config dialog."""
        Toplevel.__init__(self, master, class_='MyNotes')
        self.title(_("Preferences"))
        self.grab_set()
        self.protocol("WM_DELETE_WINDOW", self.quit)
        self.changes = {}, {}, False, False
        self.minsize(width=430, height=450)

        # --- style
        style = Style(self)
        style.theme_use("clam")
        style.configure("TScale", sliderlength=20)
        style.map("TCombobox",
                  fieldbackground=[('readonly', 'white')],
                  selectbackground=[('readonly', 'white')],
                  selectforeground=[('readonly', 'black')])
        style.configure("prev.TLabel", background="white")
        style.map("prev.TLabel", background=[("active", "white")])
        color = CONFIG.get("Categories",
                           CONFIG.get("General", "default_category"))
        style.configure("titlebar.TFrame", background=color)
        style.configure("titlebar.TLabel", background=color)
        style.configure("text.TFrame", background="white")

        # --- body
        self.notebook = Notebook(self)
        okcancel_frame = Frame(self)
        okcancel_frame.columnconfigure(0, weight=1)
        okcancel_frame.columnconfigure(1, weight=1)
        okcancel_frame.pack(fill="x", side='bottom')
        self.notebook.pack(expand=True, fill="both")

        # --- * General settings
        self._init_general()

        # --- * Font settings
        self._init_font()

        # --- * Categories
        self.category_settings = CategoryManager(self.notebook, master)
        self.notebook.add(self.category_settings,
                          text=_("Categories"),
                          sticky="ewsn",
                          padding=4)
        # --- * Symbols
        size = CONFIG.get("Font", "text_size")
        family = CONFIG.get("Font", "text_family")
        symbols_settings = Frame(self.notebook, padding=4)
        self.notebook.add(symbols_settings,
                          text=_("Symbols"),
                          sticky="ewsn",
                          padding=4)
        txt_frame = Frame(symbols_settings,
                          relief="sunken",
                          borderwidth=1,
                          style="text.TFrame")
        txt_frame.rowconfigure(0, weight=1)
        txt_frame.columnconfigure(0, weight=1)
        self.symbols = Text(txt_frame,
                            width=1,
                            height=1,
                            highlightthickness=0,
                            spacing2=5,
                            spacing1=5,
                            relief="flat",
                            padx=4,
                            pady=4,
                            font="%s %s" % (family.replace(" ", "\ "), size))
        scroll_y = AutoScrollbar(txt_frame,
                                 orient='vertical',
                                 command=self.symbols.yview)
        self.symbols.configure(yscrollcommand=scroll_y.set)

        self.symbols.insert("1.0", CONFIG.get("General", "symbols"))
        Label(symbols_settings, text=_("Available symbols")).pack(padx=4,
                                                                  pady=4)
        txt_frame.pack(fill="both", expand=True, padx=4, pady=4)
        self.symbols.grid(sticky='ewns')
        scroll_y.grid(row=0, column=1, sticky='ns')
        Button(symbols_settings, text=_('Reset'),
               command=self.reset_symbols).pack(padx=4, pady=4)

        # --- * AutoCorrect
        self.autocorrect_settings = AutoCorrectConfig(self.notebook, master)
        self.notebook.add(self.autocorrect_settings,
                          text=_("AutoCorrect"),
                          sticky="ewsn",
                          padding=4)

        # --- Ok/Cancel buttons
        Button(okcancel_frame, text="Ok", command=self.ok).grid(row=1,
                                                                column=0,
                                                                padx=4,
                                                                pady=10,
                                                                sticky="e")
        Button(okcancel_frame, text=_("Cancel"),
               command=self.destroy).grid(row=1,
                                          column=1,
                                          padx=4,
                                          pady=10,
                                          sticky="w")
Example #46
0
#     }
# ]


def save_record():
    # Obtener la información de los widgets de entrada y colocarla en la estructura de datos
    print(txt_name.get())


root = Tk()

root.geometry('350x400')
root.title('Registro de participantes')

frm_name = Frame(root)
Label(frm_name, text="Nombre").pack(side=LEFT)
txt_name = StringVar()
Entry(frm_name, textvariable=txt_name).pack(side=LEFT,
                                            padx=10,
                                            fill=X,
                                            expand=1)
frm_name.pack(fill=X, padx=10, pady=10)

frm_lastname = Frame(root)
Label(frm_lastname, text="Apellidos").pack(side=LEFT)
txt_lastname = StringVar()
Entry(frm_lastname, textvariable=txt_lastname).pack(side=LEFT,
                                                    padx=10,
                                                    fill=X,
                                                    expand=1)
frm_lastname.pack(fill=X, padx=10, pady=10)
Example #47
0
    def init_UI(self):

        self.master.title("UGLI: user-guided lesion identification")
        self.pack(fill=tk.BOTH, expand=True)

        frame1 = Frame(self)
        frame1.pack(fill=tk.X)

        bianca_button = tk.Button(
            frame1,
            text="BIANCA model",
            width=10,
            command=lambda: self.ask_for_file(self.bianca_entry))
        bianca_button.pack(side=tk.LEFT, padx=5, pady=5)

        self.bianca_entry = Entry(frame1)
        self.bianca_entry.pack(fill=tk.X, padx=5, expand=True)
        self.bianca_entry.insert(0, self.find_default_model())

        frame2 = Frame(self)
        frame2.pack(fill=tk.X)

        self.t1_button = tk.Button(
            frame2,
            text="T1 scan",
            width=10,
            command=lambda: self.ask_for_file(self.t1_entry))
        self.t1_button.pack(side=tk.LEFT, padx=5, pady=5)

        self.t1_entry = tk.Entry(frame2)
        self.t1_entry.pack(side=tk.LEFT, fill=tk.X, padx=5, expand=True)

        self.flair_button = tk.Button(
            frame2,
            text="FLAIR scan",
            width=10,
            command=lambda: self.ask_for_file(self.flair_entry))
        self.flair_button.pack(side=tk.RIGHT, padx=5, pady=5)

        self.flair_entry = tk.Entry(frame2)
        self.flair_entry.pack(side=tk.RIGHT, fill=tk.X, padx=5, expand=True)

        frame2p0625 = Frame(self)
        frame2p0625.pack(fill=tk.X)

        self.trans_button = tk.Button(
            frame2p0625,
            text="Transf. matrix",
            width=10,
            command=lambda: self.ask_for_file(self.trans_entry))
        self.trans_button.pack(side=tk.LEFT, padx=5, pady=5)

        self.trans_entry = tk.Entry(frame2p0625)
        self.trans_entry.pack(side=tk.LEFT, fill=tk.X, padx=5, expand=True)

        frame2p125 = Frame(self)
        frame2p125.pack(fill=tk.X)

        self.run_bianca_button = tk.Button(frame2p125,
                                           text="RUN BIANCA",
                                           width=40,
                                           command=self.run_bianca)
        self.run_bianca_button.pack(side=None, padx=5, pady=5)

        frame2p25 = Frame(self)
        frame2p25.pack(fill=tk.X)

        self.bg_scan = tk.StringVar()

        self.radio_t1 = tk.Radiobutton(
            frame2p25,
            text="T1",
            variable=self.bg_scan,
            value='t1',
            command=lambda: self.display_scan(self.bg_scan.get(),
                                              self.slice_slider.get()))
        self.radio_t1.pack(anchor=tk.W, padx=4, pady=3, side=tk.LEFT)

        self.radio_flair = tk.Radiobutton(
            frame2p25,
            text="FLAIR",
            variable=self.bg_scan,
            value='flair',
            command=lambda: self.display_scan(self.bg_scan.get(),
                                              self.slice_slider.get()))
        self.radio_flair.pack(anchor=tk.W, padx=4, pady=3, side=tk.LEFT)

        self.mask_on = tk.BooleanVar()

        self.mask_on_checkbox = tk.Checkbutton(
            frame2p25,
            text="Mask on",
            variable=self.mask_on,
            command=lambda: self.display_scan(self.bg_scan.get(),
                                              self.slice_slider.get()))
        self.mask_on_checkbox.pack(anchor=tk.W, padx=4, pady=3, side=tk.LEFT)

        alpha_label = tk.Label(frame2p25,
                               text="Mask alpha",
                               width=10,
                               command=None)
        alpha_label.pack(side=tk.LEFT, padx=1, pady=3)

        self.alpha_entry = Entry(frame2p25)
        self.alpha_entry.pack(fill=tk.X, padx=4, expand=False, side=tk.LEFT)

        t1_max_label = tk.Label(frame2p25, text="T1 max", width=10)
        t1_max_label.pack(side=tk.LEFT, padx=1, pady=3)

        self.t1_max = Entry(frame2p25)
        self.t1_max.pack(fill=tk.X, padx=4, expand=False, side=tk.LEFT)

        flair_max_label = tk.Label(frame2p25, text="FLAIR max", width=10)
        flair_max_label.pack(side=tk.LEFT, padx=1, pady=3)

        self.flair_max = Entry(frame2p25)
        self.flair_max.pack(fill=tk.X, padx=4, expand=False, side=tk.LEFT)

        frame2p5 = Frame(self)
        frame2p5.pack(fill=tk.X)

        self.binarize_probability_mask_button = tk.Button(
            frame2p5,
            text="Binarize mask",
            width=10,
            command=self.binarize_probability_mask)
        self.binarize_probability_mask_button.pack(padx=2,
                                                   pady=2,
                                                   side=tk.LEFT,
                                                   anchor=tk.S)

        self.binarize_slider = tk.Scale(
            frame2p5,
            from_=1,
            to=99,
            orient=tk.HORIZONTAL,
            command=lambda x: self.display_scan(self.bg_scan.get(),
                                                self.slice_slider.get()))
        self.binarize_slider.pack(fill=tk.X, padx=2, pady=2, expand=True)

        self.frame3 = Frame(self)
        self.frame3.pack(fill=tk.BOTH, expand=True)

        ### PLOT STUFF

        # adding the subplot
        self.fig = plt.Figure(figsize=(6, 6), dpi=100)
        self.plot1 = self.fig.add_subplot(111)
        self.plot1.axis('off')

        # PLOT STUFF

        slice_label = Label(self.frame3, text="Slice", width=1, wraplength=1)
        slice_label.pack(side=tk.RIGHT, padx=2, pady=2, anchor=tk.CENTER)

        self.slice_slider = tk.Scale(
            self.frame3,
            from_=10,
            to=0,
            orient=tk.VERTICAL,
            command=lambda x: self.display_scan(self.bg_scan.get(),
                                                self.slice_slider.get()))
        self.slice_slider.pack(side=tk.RIGHT,
                               fill=tk.BOTH,
                               padx=2,
                               pady=2,
                               expand=False)

        frame4 = Frame(self)
        frame4.pack(fill=None, expand=False)

        self.display_label = tk.Label(frame4,
                                      text="Step 0: initialization",
                                      width=30)
        self.display_label.pack(side=tk.BOTTOM, padx=5, pady=5)

        frame5 = Frame(self)
        frame5.pack(fill=tk.BOTH, expand=False)

        global_ops_label = Label(frame5,
                                 text="Global morphological operations",
                                 width=25)
        global_ops_label.pack(padx=2, pady=0, side=tk.TOP, anchor=tk.NW)

        #finishing_label = Label(frame5, text="Final operations", width=25)
        #finishing_label.pack(padx=2, pady=0, side=tk.TOP, anchor=tk.NE)

        self.erode_button = tk.Button(
            frame5,
            text="ERODE",
            width=10,
            command=lambda: self.alter_all_slices(mor.binary_erosion))
        self.erode_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.dilate_button = tk.Button(
            frame5,
            text="DILATE",
            width=10,
            command=lambda: self.alter_all_slices(mor.binary_dilation))
        self.dilate_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.open_button = tk.Button(
            frame5,
            text="OPEN",
            width=10,
            command=lambda: self.alter_all_slices(mor.binary_opening))
        self.open_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.close_button = tk.Button(
            frame5,
            text="CLOSE",
            width=10,
            command=lambda: self.alter_all_slices(mor.binary_closing))
        self.close_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.zero_button = tk.Button(
            frame5,
            text="ZERO",
            width=10,
            command=lambda: self.alter_all_slices(self.set_slice_zero))
        self.zero_button.pack(padx=2, pady=1, side=tk.LEFT)

        top_buffer = tk.Label(frame5, text="|", width=5)
        top_buffer.pack(padx=2, pady=0, side=tk.LEFT)

        self.slice_up_button = tk.Button(frame5,
                                         text="Slice up",
                                         width=12,
                                         command=self.slice_up)
        self.slice_up_button.pack(padx=6, pady=1, side=tk.LEFT)

        self.save_mask_button = tk.Button(frame5,
                                          text="Save mask",
                                          width=12,
                                          command=self.write_binarized_file)
        self.save_mask_button.pack(padx=6, pady=1, side=tk.RIGHT)

        self.calculate_stats_button = tk.Button(frame5,
                                                text="Show statistics",
                                                width=12,
                                                command=self.stats_popup)
        self.calculate_stats_button.pack(padx=6, pady=1, side=tk.RIGHT)

        frame6 = Frame(self)
        frame6.pack(fill=tk.BOTH, expand=False)

        local_ops_label = tk.Label(
            frame6, text="Local morphological operations         ", width=25)
        local_ops_label.pack(padx=2, pady=0, side=tk.TOP, anchor=tk.NW)

        self.local_erode_button = tk.Button(
            frame6,
            text="ERODE",
            width=10,
            command=lambda: self.alter_current_slice(mor.binary_erosion))
        self.local_erode_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.local_dilate_button = tk.Button(
            frame6,
            text="DILATE",
            width=10,
            command=lambda: self.alter_current_slice(mor.binary_dilation))
        self.local_dilate_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.local_open_button = tk.Button(
            frame6,
            text="OPEN",
            width=10,
            command=lambda: self.alter_current_slice(mor.binary_opening))
        self.local_open_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.local_close_button = tk.Button(
            frame6,
            text="CLOSE",
            width=10,
            command=lambda: self.alter_current_slice(mor.binary_closing))
        self.local_close_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.local_zero_button = tk.Button(
            frame6,
            text="ZERO",
            width=10,
            command=lambda: self.alter_current_slice(self.set_slice_zero))
        self.local_zero_button.pack(padx=2, pady=1, side=tk.LEFT)

        bottom_buffer = tk.Label(frame6, text="|", width=5)
        bottom_buffer.pack(padx=2, pady=0, side=tk.LEFT)

        self.slice_down_button = tk.Button(frame6,
                                           text="Slice down",
                                           width=12,
                                           command=self.slice_down)
        self.slice_down_button.pack(padx=6, pady=1, side=tk.LEFT)

        self.return_to_binarization_button = tk.Button(
            frame6,
            text="Back to binarization",
            width=12,
            command=self.return_to_binarization_cmd)
        self.return_to_binarization_button.pack(padx=6, pady=1, side=tk.RIGHT)

        self.undo_morph_button = tk.Button(frame6,
                                           text="Undo",
                                           width=12,
                                           command=self.undo_morph)
        self.undo_morph_button.pack(padx=6, pady=1, side=tk.RIGHT)

        frame7 = Frame(self)
        frame7.pack(fill=tk.BOTH, expand=False)

        roi_label = tk.Label(frame7,
                             text="Region selection operations              ",
                             width=25)
        roi_label.pack(padx=2, pady=0, side=tk.TOP, anchor=tk.NW)

        self.lasso_area_button = tk.Button(frame7,
                                           text="LASSO",
                                           width=10,
                                           command=self.lasso_region)
        self.lasso_area_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.finish_lasso_button = tk.Button(frame7,
                                             text="CANCEL LASSO",
                                             width=10,
                                             command=self.finish_lasso)
        self.finish_lasso_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.keep_area_button = tk.Button(frame7,
                                          text="Keep",
                                          width=10,
                                          command=self.keep_lassoed_areas)
        self.keep_area_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.exclude_area_button = tk.Button(frame7,
                                             text="Delete",
                                             width=10,
                                             command=self.delete_lassoed_areas)
        self.exclude_area_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.fill_area_button = tk.Button(frame7,
                                          text="Fill",
                                          width=10,
                                          command=self.fill_lassoed_areas)
        self.fill_area_button.pack(padx=2, pady=1, side=tk.LEFT)

        frame8 = Frame(self)
        frame8.pack(fill=tk.BOTH, expand=False)

        roi_label = tk.Label(frame8,
                             text="Geometry sieving operations           ",
                             width=25)
        roi_label.pack(padx=2, pady=0, side=tk.TOP, anchor=tk.NW)

        self.gbs_sci_button = tk.Button(frame8,
                                        text="GBS SCI",
                                        width=10,
                                        command=self.gbs_sci)
        self.gbs_sci_button.pack(padx=2, pady=1, side=tk.LEFT)

        self.n_writes = 0
        self.stage = 0

        # set up the overlay cmap

        viridis = matplotlib.cm.get_cmap('viridis', 256)
        newcolors1 = viridis(np.linspace(0, 1, 256))
        newcolors2 = viridis(np.linspace(0, 1, 256))

        red = np.array([255 / 255, 0 / 255, 0 / 255, 1])
        clear_blue = np.array([0 / 255, 0 / 255, 255 / 255, 0.05])
        maroon = np.array([128 / 255, 0 / 255, 0 / 255, 1])
        clear_navy = np.array([0 / 255, 0 / 255, 128 / 255, 0.05])

        blue = np.array([0 / 255, 0 / 255, 255 / 255, 1])
        navy = np.array([0 / 255, 0 / 255, 128 / 255, 1])

        green = np.array([0 / 255, 255 / 255, 0 / 255, 1])

        newcolors1[:128, :] = clear_blue
        newcolors1[128:, :] = red

        self.probability_cmp = matplotlib.colors.ListedColormap(newcolors1)

        newcolors2[:128, :] = clear_navy
        newcolors2[128:, :] = green

        self.binary_cmp = matplotlib.colors.ListedColormap(newcolors2)

        self.stage = 1
        self.setup_stage(1)
Example #48
0
    for deleted_file in all_deleted_files:
        full_target_path = path.join(target_path.get(), deleted_file)
        remove(full_target_path)
        progress_value.set(progress_value.get() + step)

    progress_value.set(100)


# ------------- GUI ------------- #
# Configure window
window.title("Folder syncer")
window.geometry("560x250")

# Source folder label
Label(window, text="Source folder:").grid(row=0, column=0)

# Source folder entry
Entry(window, textvariable=source_path).grid(row=1, column=0)

# Source folder button
Button(window, command=chose_source_folder,
       text="Get source folder").grid(row=1, column=1)

# Target folder label
Label(window, text="Target folder:").grid(row=0, column=3)

# Target folder entry
Entry(window, textvariable=target_path).grid(row=1, column=3)

# Target folder button
Example #49
0
    def initUI(self):

        self.master.title("Absolute positioning")
        self.pack(fill=BOTH, expand=1)

        Style().configure("TFrame", background="#333")

        bard = Image.open("bardejov.jpg")
        bardjov = ImageTk.PhotoImage(bard)
        label1 = Label(self, image=bardjov)
        label1.image = bardjov
        label1.place(x=20, y=20)

        rot = Image.open("rotunda.jpg")
        rotunda = ImageTk.PhotoImage(rot)
        label2 = Label(self, image=rotunda)
        label2.image = rotunda
        label2.place(x=40, y=40)

        minc = Image.open("mincol.jpg")
        mincol = ImageTk.PhotoImage(minc)
        label3 = Label(self, image=mincol)
        label3.image = mincol
        label3.place(x=170, y=170)
Example #50
0
    def initUI(self):
      
        self.master.title("Review")
        self.pack(fill=BOTH, expand=True)
        
        frame1 = Frame(self)
        frame1.pack(fill=X)
        
        lbl1 = Label(frame1, text="TASK", width=10)
        lbl1.pack(side=LEFT, padx=5, pady=5)           
       
        entry1 = Entry(frame1)
        entry1.pack(fill=X, padx=5, expand=True)
        
        frame2 = Frame(self)
        frame2.pack(fill=X)
        
        lbl2 = Label(frame2, text="PROJECT", width=10)
        lbl2.pack(side=LEFT, padx=4, pady=5)        

        entry2 = Entry(frame2)
        entry2.pack(fill=X, padx=5, expand=True)
		frame3=Frame(self)
		frame3.pack(fill=x)
		
		lbl3=Label(frame3,text="status",width=10)
		lbl3.pack(side=LEFT,padx=5,pady=5)    
class DialogPluginManager(Toplevel):
    def __init__(self, mainWin, modulesWithNewerFileDates):
        super(DialogPluginManager, self).__init__(mainWin.parent)

        self.ENABLE = _("Enable")
        self.DISABLE = _("Disable")
        self.parent = mainWin.parent
        self.cntlr = mainWin

        # copy plugins for temporary display
        self.pluginConfig = PluginManager.pluginConfig
        self.pluginConfigChanged = False
        self.uiClassMethodsChanged = False
        self.modelClassesChanged = False
        self.customTransformsChanged = False
        self.disclosureSystemTypesChanged = False
        self.hostSystemFeaturesChanged = False
        self.modulesWithNewerFileDates = modulesWithNewerFileDates

        parentGeometry = re.match("(\d+)x(\d+)[+]?([-]?\d+)[+]?([-]?\d+)",
                                  self.parent.geometry())
        dialogX = int(parentGeometry.group(3))
        dialogY = int(parentGeometry.group(4))

        self.title(_("Plug-in Manager"))
        frame = Frame(self)

        # left button frame
        buttonFrame = Frame(frame, width=40)
        buttonFrame.columnconfigure(0, weight=1)
        addLabel = Label(buttonFrame,
                         text=_("Find plug-in modules:"),
                         wraplength=60,
                         justify="center")
        addSelectLocalButton = Button(buttonFrame,
                                      text=_("Select"),
                                      command=self.selectLocally)
        ToolTip(
            addSelectLocalButton,
            text=_(
                "Select python module files from the local plugin directory."),
            wraplength=240)
        addBrowseLocalButton = Button(buttonFrame,
                                      text=_("Browse"),
                                      command=self.browseLocally)
        ToolTip(
            addBrowseLocalButton,
            text=
            _("File chooser allows browsing and selecting python module files to add (or reload) plug-ins, from the local file system."
              ),
            wraplength=240)
        addWebButton = Button(buttonFrame,
                              text=_("On Web"),
                              command=self.findOnWeb)
        ToolTip(
            addWebButton,
            text=
            _("Dialog to enter URL full path to load (or reload) plug-ins, from the web or local file system."
              ),
            wraplength=240)
        addLabel.grid(row=0, column=0, pady=4)
        addSelectLocalButton.grid(row=1, column=0, pady=4)
        addBrowseLocalButton.grid(row=2, column=0, pady=4)
        addWebButton.grid(row=3, column=0, pady=4)
        buttonFrame.grid(row=0,
                         column=0,
                         rowspan=3,
                         sticky=(N, S, W),
                         padx=3,
                         pady=3)

        # right tree frame (plugins already known to arelle)
        modulesFrame = Frame(frame, width=720)
        vScrollbar = Scrollbar(modulesFrame, orient=VERTICAL)
        hScrollbar = Scrollbar(modulesFrame, orient=HORIZONTAL)
        self.modulesView = Treeview(modulesFrame,
                                    xscrollcommand=hScrollbar.set,
                                    yscrollcommand=vScrollbar.set,
                                    height=7)
        self.modulesView.grid(row=0, column=0, sticky=(N, S, E, W))
        self.modulesView.bind('<<TreeviewSelect>>', self.moduleSelect)
        hScrollbar["command"] = self.modulesView.xview
        hScrollbar.grid(row=1, column=0, sticky=(E, W))
        vScrollbar["command"] = self.modulesView.yview
        vScrollbar.grid(row=0, column=1, sticky=(N, S))
        modulesFrame.columnconfigure(0, weight=1)
        modulesFrame.rowconfigure(0, weight=1)
        modulesFrame.grid(row=0,
                          column=1,
                          columnspan=4,
                          sticky=(N, S, E, W),
                          padx=3,
                          pady=3)
        self.modulesView.focus_set()

        self.modulesView.column("#0", width=120, anchor="w")
        self.modulesView.heading("#0", text=_("Name"))
        self.modulesView["columns"] = ("author", "ver", "status", "date",
                                       "update", "descr", "license")
        self.modulesView.column("author", width=100, anchor="w", stretch=False)
        self.modulesView.heading("author", text=_("Author"))
        self.modulesView.column("ver", width=60, anchor="w", stretch=False)
        self.modulesView.heading("ver", text=_("Version"))
        self.modulesView.column("status", width=50, anchor="w", stretch=False)
        self.modulesView.heading("status", text=_("Status"))
        self.modulesView.column("date", width=70, anchor="w", stretch=False)
        self.modulesView.heading("date", text=_("File Date"))
        self.modulesView.column("update", width=50, anchor="w", stretch=False)
        self.modulesView.heading("update", text=_("Update"))
        self.modulesView.column("descr", width=200, anchor="w", stretch=False)
        self.modulesView.heading("descr", text=_("Description"))
        self.modulesView.column("license", width=70, anchor="w", stretch=False)
        self.modulesView.heading("license", text=_("License"))

        classesFrame = Frame(frame)
        vScrollbar = Scrollbar(classesFrame, orient=VERTICAL)
        hScrollbar = Scrollbar(classesFrame, orient=HORIZONTAL)
        self.classesView = Treeview(classesFrame,
                                    xscrollcommand=hScrollbar.set,
                                    yscrollcommand=vScrollbar.set,
                                    height=5)
        self.classesView.grid(row=0, column=0, sticky=(N, S, E, W))
        hScrollbar["command"] = self.classesView.xview
        hScrollbar.grid(row=1, column=0, sticky=(E, W))
        vScrollbar["command"] = self.classesView.yview
        vScrollbar.grid(row=0, column=1, sticky=(N, S))
        classesFrame.columnconfigure(0, weight=1)
        classesFrame.rowconfigure(0, weight=1)
        classesFrame.grid(row=1,
                          column=1,
                          columnspan=4,
                          sticky=(N, S, E, W),
                          padx=3,
                          pady=3)
        self.classesView.focus_set()

        self.classesView.column("#0", width=200, anchor="w")
        self.classesView.heading("#0", text=_("Class"))
        self.classesView["columns"] = ("modules", )
        self.classesView.column("modules",
                                width=500,
                                anchor="w",
                                stretch=False)
        self.classesView.heading("modules", text=_("Modules"))

        # bottom frame module info details
        moduleInfoFrame = Frame(frame, width=700)
        moduleInfoFrame.columnconfigure(1, weight=1)

        self.moduleNameLabel = Label(moduleInfoFrame,
                                     wraplength=600,
                                     justify="left",
                                     font=font.Font(family='Helvetica',
                                                    size=12,
                                                    weight='bold'))
        self.moduleNameLabel.grid(row=0, column=0, columnspan=4, sticky=W)
        self.moduleAuthorHdr = Label(moduleInfoFrame,
                                     text=_("author:"),
                                     state=DISABLED)
        self.moduleAuthorHdr.grid(row=1, column=0, sticky=W)
        self.moduleAuthorLabel = Label(moduleInfoFrame,
                                       wraplength=600,
                                       justify="left")
        self.moduleAuthorLabel.grid(row=1, column=1, columnspan=3, sticky=W)
        self.moduleDescrHdr = Label(moduleInfoFrame,
                                    text=_("description:"),
                                    state=DISABLED)
        self.moduleDescrHdr.grid(row=2, column=0, sticky=W)
        self.moduleDescrLabel = Label(moduleInfoFrame,
                                      wraplength=600,
                                      justify="left")
        self.moduleDescrLabel.grid(row=2, column=1, columnspan=3, sticky=W)
        self.moduleClassesHdr = Label(moduleInfoFrame,
                                      text=_("classes:"),
                                      state=DISABLED)
        self.moduleClassesHdr.grid(row=3, column=0, sticky=W)
        self.moduleClassesLabel = Label(moduleInfoFrame,
                                        wraplength=600,
                                        justify="left")
        self.moduleClassesLabel.grid(row=3, column=1, columnspan=3, sticky=W)
        ToolTip(self.moduleClassesLabel,
                text=_("List of classes that this plug-in handles."),
                wraplength=240)
        self.moduleVersionHdr = Label(moduleInfoFrame,
                                      text=_("Version:"),
                                      state=DISABLED)
        self.moduleVersionHdr.grid(row=4, column=0, sticky=W)
        self.moduleVersionLabel = Label(moduleInfoFrame,
                                        wraplength=600,
                                        justify="left")
        self.moduleVersionLabel.grid(row=4, column=1, columnspan=3, sticky=W)
        ToolTip(self.moduleVersionLabel,
                text=_("Version of plug-in module."),
                wraplength=240)
        self.moduleUrlHdr = Label(moduleInfoFrame,
                                  text=_("URL:"),
                                  state=DISABLED)
        self.moduleUrlHdr.grid(row=5, column=0, sticky=W)
        self.moduleUrlLabel = Label(moduleInfoFrame,
                                    wraplength=600,
                                    justify="left")
        self.moduleUrlLabel.grid(row=5, column=1, columnspan=3, sticky=W)
        ToolTip(
            self.moduleUrlLabel,
            text=_(
                "URL of plug-in module (local file path or web loaded file)."),
            wraplength=240)
        self.moduleDateHdr = Label(moduleInfoFrame,
                                   text=_("date:"),
                                   state=DISABLED)
        self.moduleDateHdr.grid(row=6, column=0, sticky=W)
        self.moduleDateLabel = Label(moduleInfoFrame,
                                     wraplength=600,
                                     justify="left")
        self.moduleDateLabel.grid(row=6, column=1, columnspan=3, sticky=W)
        ToolTip(
            self.moduleDateLabel,
            text=
            _("Date of currently loaded module file (with parenthetical node when an update is available)."
              ),
            wraplength=240)
        self.moduleLicenseHdr = Label(moduleInfoFrame,
                                      text=_("license:"),
                                      state=DISABLED)
        self.moduleLicenseHdr.grid(row=7, column=0, sticky=W)
        self.moduleLicenseLabel = Label(moduleInfoFrame,
                                        wraplength=600,
                                        justify="left")
        self.moduleLicenseLabel.grid(row=7, column=1, columnspan=3, sticky=W)
        self.moduleImportsHdr = Label(moduleInfoFrame,
                                      text=_("imports:"),
                                      state=DISABLED)
        self.moduleImportsHdr.grid(row=8, column=0, sticky=W)
        self.moduleImportsLabel = Label(moduleInfoFrame,
                                        wraplength=600,
                                        justify="left")
        self.moduleImportsLabel.grid(row=8, column=1, columnspan=3, sticky=W)
        self.moduleEnableButton = Button(moduleInfoFrame,
                                         text=self.ENABLE,
                                         state=DISABLED,
                                         command=self.moduleEnable)
        ToolTip(self.moduleEnableButton,
                text=_("Enable/disable plug in."),
                wraplength=240)
        self.moduleEnableButton.grid(row=9, column=1, sticky=E)
        self.moduleReloadButton = Button(moduleInfoFrame,
                                         text=_("Reload"),
                                         state=DISABLED,
                                         command=self.moduleReload)
        ToolTip(self.moduleReloadButton,
                text=_("Reload/update plug in."),
                wraplength=240)
        self.moduleReloadButton.grid(row=9, column=2, sticky=E)
        self.moduleRemoveButton = Button(moduleInfoFrame,
                                         text=_("Remove"),
                                         state=DISABLED,
                                         command=self.moduleRemove)
        ToolTip(
            self.moduleRemoveButton,
            text=
            _("Remove plug in from plug in table (does not erase the plug in's file)."
              ),
            wraplength=240)
        self.moduleRemoveButton.grid(row=9, column=3, sticky=E)
        moduleInfoFrame.grid(row=2,
                             column=0,
                             columnspan=5,
                             sticky=(N, S, E, W),
                             padx=3,
                             pady=3)
        moduleInfoFrame.config(borderwidth=4, relief="groove")

        okButton = Button(frame, text=_("Close"), command=self.ok)
        ToolTip(okButton,
                text=_("Accept and changes (if any) and close dialog."),
                wraplength=240)
        cancelButton = Button(frame, text=_("Cancel"), command=self.close)
        ToolTip(cancelButton,
                text=_("Cancel changes (if any) and close dialog."),
                wraplength=240)
        okButton.grid(row=3, column=3, sticky=(S, E), pady=3)
        cancelButton.grid(row=3, column=4, sticky=(S, E), pady=3, padx=3)

        enableDisableFrame = Frame(frame)
        enableDisableFrame.grid(row=3, column=1, sticky=(S, W), pady=3)
        enableAllButton = Button(enableDisableFrame,
                                 text=_("Enable All"),
                                 command=self.enableAll)
        ToolTip(enableAllButton,
                text=_("Enable all plug ins."),
                wraplength=240)
        disableAllButton = Button(enableDisableFrame,
                                  text=_("Disable All"),
                                  command=self.disableAll)
        ToolTip(disableAllButton,
                text=_("Disable all plug ins."),
                wraplength=240)
        enableAllButton.grid(row=1, column=1)
        disableAllButton.grid(row=1, column=2)

        self.loadTreeViews()

        self.geometry("+{0}+{1}".format(dialogX + 50, dialogY + 100))
        frame.grid(row=0, column=0, sticky=(N, S, E, W))
        frame.columnconfigure(0, weight=0)
        frame.columnconfigure(1, weight=1)
        frame.rowconfigure(0, weight=1)
        window = self.winfo_toplevel()
        window.columnconfigure(0, weight=1)
        window.rowconfigure(0, weight=1)

        self.bind("<Return>", self.ok)
        self.bind("<Escape>", self.close)

        self.protocol("WM_DELETE_WINDOW", self.close)
        self.grab_set()
        self.wait_window(self)

    def loadTreeViews(self):
        self.selectedModule = None

        # clear previous treeview entries
        for previousNode in self.modulesView.get_children(""):
            self.modulesView.delete(previousNode)

        def loadSubtree(parentNode, moduleItems):
            for moduleItem in sorted(moduleItems, key=lambda item: item[0]):
                moduleInfo = moduleItem[1]
                if parentNode or not moduleInfo.get("isImported"):
                    nodeName = moduleItem[0]
                    if parentNode:
                        nodeName = parentNode + GROUPSEP + nodeName
                    name = moduleInfo.get("name", nodeName)
                    node = self.modulesView.insert(parentNode,
                                                   "end",
                                                   nodeName,
                                                   text=name)
                    self.modulesView.set(node, "author",
                                         moduleInfo.get("author"))
                    self.modulesView.set(node, "ver",
                                         moduleInfo.get("version"))
                    self.modulesView.set(node, "status",
                                         moduleInfo.get("status"))
                    self.modulesView.set(node, "date",
                                         moduleInfo.get("fileDate"))
                    if name in self.modulesWithNewerFileDates:
                        self.modulesView.set(node, "update", _("available"))
                    self.modulesView.set(node, "descr",
                                         moduleInfo.get("description"))
                    self.modulesView.set(node, "license",
                                         moduleInfo.get("license"))
                    if moduleInfo.get("imports"):
                        loadSubtree(
                            node,
                            [(importModuleInfo["name"], importModuleInfo)
                             for importModuleInfo in moduleInfo["imports"]])

        loadSubtree("", self.pluginConfig.get("modules", {}).items())

        # clear previous treeview entries
        for previousNode in self.classesView.get_children(""):
            self.classesView.delete(previousNode)

        for i, classItem in enumerate(
                sorted(self.pluginConfig.get("classes", {}).items())):
            className, moduleList = classItem
            node = self.classesView.insert("",
                                           "end",
                                           className,
                                           text=className)
            self.classesView.set(node, "modules", ', '.join(moduleList))

        self.moduleSelect()  # clear out prior selection

    def ok(self, event=None):
        # check for orphaned classes (for which there is no longer a corresponding module)
        _moduleNames = self.pluginConfig.get("modules", {}).keys()
        _orphanedClassNames = set()
        for className, moduleList in self.pluginConfig.get("classes",
                                                           {}).items():
            for _moduleName in moduleList.copy():
                if _moduleName not in _moduleNames:  # it's orphaned
                    moduleList.remove(_moduleName)
                    self.pluginConfigChanged = True
            if not moduleList:  # now orphaned
                _orphanedClassNames.add(className)
                self.pluginConfigChanged = True
        for _orphanedClassName in _orphanedClassNames:
            del self.pluginConfig["classes"][_orphanedClassName]

        if self.pluginConfigChanged:
            PluginManager.pluginConfig = self.pluginConfig
            PluginManager.pluginConfigChanged = True
            PluginManager.reset()  # force reloading of modules
        if self.uiClassMethodsChanged or self.modelClassesChanged or self.customTransformsChanged or self.disclosureSystemTypesChanged or self.hostSystemFeaturesChanged:  # may require reloading UI
            affectedItems = ""
            if self.uiClassMethodsChanged:
                affectedItems += _("menus of the user interface")
            if self.modelClassesChanged:
                if affectedItems:
                    affectedItems += _(" and ")
                affectedItems += _("model objects of the processor")
            if self.customTransformsChanged:
                if affectedItems:
                    affectedItems += _(" and ")
                affectedItems += _("custom transforms")
            if self.disclosureSystemTypesChanged:
                if affectedItems:
                    affectedItems += _(" and ")
                affectedItems += _("disclosure system types")
            if self.hostSystemFeaturesChanged:
                if affectedItems:
                    affectedItems += _(" and ")
                affectedItems += _("host system features")
            if messagebox.askyesno(
                    _("User interface plug-in change"),
                    _("A change in plug-in class methods may have affected {0}.  "
                      "Please restart Arelle to due to these changes.  \n\n"
                      "Should Arelle restart itself now "
                      "(if there are any unsaved changes they would be lost!)?"
                      ).format(affectedItems),
                    parent=self):
                self.cntlr.uiThreadQueue.put((self.cntlr.quit, [None, True]))
        self.close()

    def close(self, event=None):
        self.parent.focus_set()
        self.destroy()

    def moduleSelect(self, *args):
        node = (self.modulesView.selection() or (None, ))[0]
        if node:
            node = node.rpartition(GROUPSEP)[
                2]  # drop leading path names for module name
        moduleInfo = self.pluginConfig.get("modules", {}).get(node)
        if moduleInfo:
            self.selectedModule = node
            name = moduleInfo["name"]
            self.moduleNameLabel.config(text=name)
            self.moduleAuthorHdr.config(state=ACTIVE)
            self.moduleAuthorLabel.config(text=moduleInfo.get("author"))
            self.moduleDescrHdr.config(state=ACTIVE)
            self.moduleDescrLabel.config(text=moduleInfo.get("description"))
            self.moduleClassesHdr.config(state=ACTIVE)
            self.moduleClassesLabel.config(
                text=', '.join(moduleInfo["classMethods"]))
            self.moduleVersionHdr.config(state=ACTIVE)
            self.moduleVersionLabel.config(text=moduleInfo.get("version"))
            self.moduleUrlHdr.config(state=ACTIVE)
            self.moduleUrlLabel.config(text=moduleInfo["moduleURL"])
            self.moduleDateHdr.config(state=ACTIVE)
            self.moduleDateLabel.config(
                text=moduleInfo["fileDate"] + " " +
                (_("(an update is available)") if name in
                 self.modulesWithNewerFileDates else ""))
            self.moduleLicenseHdr.config(state=ACTIVE)
            self.moduleLicenseLabel.config(text=moduleInfo["license"])
            if moduleInfo.get("imports"):
                self.moduleImportsHdr.config(state=ACTIVE)
                _text = ", ".join(mi["name"]
                                  for mi in moduleInfo["imports"][:3])
                if len(moduleInfo["imports"]) >= 3:
                    _text += ", ..."
                self.moduleImportsLabel.config(text=_text)
            _buttonState = DISABLED if moduleInfo.get("isImported") else ACTIVE
            self.moduleEnableButton.config(state=_buttonState,
                                           text={
                                               "enabled": self.DISABLE,
                                               "disabled": self.ENABLE
                                           }[moduleInfo["status"]])
            self.moduleReloadButton.config(state=_buttonState)
            self.moduleRemoveButton.config(state=_buttonState)
        else:
            self.selectedModule = None
            self.moduleNameLabel.config(text="")
            self.moduleAuthorHdr.config(state=DISABLED)
            self.moduleAuthorLabel.config(text="")
            self.moduleDescrHdr.config(state=DISABLED)
            self.moduleDescrLabel.config(text="")
            self.moduleClassesHdr.config(state=DISABLED)
            self.moduleClassesLabel.config(text="")
            self.moduleVersionHdr.config(state=DISABLED)
            self.moduleVersionLabel.config(text="")
            self.moduleUrlHdr.config(state=DISABLED)
            self.moduleUrlLabel.config(text="")
            self.moduleDateHdr.config(state=DISABLED)
            self.moduleDateLabel.config(text="")
            self.moduleLicenseHdr.config(state=DISABLED)
            self.moduleLicenseLabel.config(text="")
            self.moduleImportsHdr.config(state=DISABLED)
            self.moduleImportsLabel.config(text="")
            self.moduleEnableButton.config(state=DISABLED, text=self.ENABLE)
            self.moduleReloadButton.config(state=DISABLED)
            self.moduleRemoveButton.config(state=DISABLED)

    def selectLocally(self):
        choices = []  # list of tuple of (file name, description)

        def sortOrder(key):
            return {
                "EdgarRenderer": "1",
                "validate": "2",
                "xbrlDB": "3"
            }.get(key, "4") + key.lower()

        def selectChoices(dir, indent=""):
            dirHasEntries = False
            for f in sorted(os.listdir(dir), key=sortOrder):
                if f not in (".", "..", "__pycache__", "__init__.py"):
                    fPath = os.path.join(dir, f)
                    fPkgInit = os.path.join(fPath, "__init__.py")
                    dirInsertPoint = len(choices)
                    moduleInfo = None
                    if ((os.path.isdir(fPath) and os.path.exists(fPkgInit)) or
                        ((os.path.isfile(fPath) and f.endswith(".py")))):
                        moduleInfo = PluginManager.moduleModuleInfo(fPath)
                        if moduleInfo:
                            choices.append((
                                indent + f,
                                "name: {}\ndescription: {}\nversion: {}\nlicense: {}"
                                .format(moduleInfo["name"],
                                        moduleInfo["description"],
                                        moduleInfo.get("version"),
                                        moduleInfo.get("license")), fPath,
                                moduleInfo["name"], moduleInfo.get("version"),
                                moduleInfo["description"],
                                moduleInfo.get("license")))
                            dirHasEntries = True
                    if os.path.isdir(fPath) and f not in ("DQC_US_Rules", ):
                        if selectChoices(fPath, indent=indent +
                                         "   ") and not moduleInfo:
                            choices.insert(dirInsertPoint,
                                           (indent + f, None, None, None, None,
                                            None, None))
            return dirHasEntries

        selectChoices(self.cntlr.pluginDir)
        selectedPath = DialogOpenArchive.selectPlugin(self, choices)
        if selectedPath:
            moduleInfo = PluginManager.moduleModuleInfo(selectedPath)
            self.loadFoundModuleInfo(moduleInfo, selectedPath)

    def browseLocally(self):
        initialdir = self.cntlr.pluginDir  # default plugin directory
        if not self.cntlr.isMac:  # can't navigate within app easily, always start in default directory
            initialdir = self.cntlr.config.setdefault("pluginOpenDir",
                                                      initialdir)
        filename = self.cntlr.uiFileDialog(
            "open",
            parent=self,
            title=_("Choose plug-in module file"),
            initialdir=initialdir,
            filetypes=[(_("Python files"), "*.py")],
            defaultextension=".py")
        if filename:
            # check if a package is selected (any file in a directory containing an __init__.py
            #if (os.path.basename(filename) == "__init__.py" and os.path.isdir(os.path.dirname(filename)) and
            #    os.path.isfile(filename)):
            #    filename = os.path.dirname(filename) # refer to the package instead
            self.cntlr.config["pluginOpenDir"] = os.path.dirname(filename)
            moduleInfo = PluginManager.moduleModuleInfo(filename)
            self.loadFoundModuleInfo(moduleInfo, filename)

    def findOnWeb(self):
        url = DialogURL.askURL(self)
        if url:  # url is the in-cache or local file
            moduleInfo = PluginManager.moduleModuleInfo(url)
            self.cntlr.showStatus("")  # clear web loading status
            self.loadFoundModuleInfo(moduleInfo, url)

    def loadFoundModuleInfo(self, moduleInfo, url):
        if moduleInfo and moduleInfo.get("name"):
            self.addPluginConfigModuleInfo(moduleInfo)
            self.loadTreeViews()
        else:
            messagebox.showwarning(
                _("Module is not itself a plug-in or in a directory with package __init__.py plug-in.  "
                  ),
                _("File does not itself contain a python program with an appropriate __pluginInfo__ declaration: \n\n{0}"
                  ).format(url),
                parent=self)

    def checkIfImported(self, moduleInfo):
        if moduleInfo.get("isImported"):
            messagebox.showwarning(
                _("Plug-in is imported by a parent plug-in.  "),
                _("Plug-in has a parent, please request operation on the parent: \n\n{0}"
                  ).format(moduleInfo.get("name")),
                parent=self)
            return True
        return False

    def checkClassMethodsChanged(self, moduleInfo):
        for classMethod in moduleInfo["classMethods"]:
            if classMethod.startswith("CntlrWinMain.Menu"):
                self.uiClassMethodsChanged = True  # may require reloading UI
            elif classMethod == "ModelObjectFactory.ElementSubstitutionClasses":
                self.modelClassesChanged = True  # model object factor classes changed
            elif classMethod == "ModelManager.LoadCustomTransforms":
                self.customTransformsChanged = True
            elif classMethod == "DisclosureSystem.Types":
                self.disclosureSystemTypesChanged = True  # disclosure system types changed
            elif classMethod.startswith("Proxy."):
                self.hostSystemFeaturesChanged = True  # system features (e.g., proxy) changed

    def removePluginConfigModuleInfo(self, name):
        moduleInfo = self.pluginConfig["modules"].get(name)
        if moduleInfo:
            if self.checkIfImported(moduleInfo):
                return

            def _removePluginConfigModuleInfo(moduleInfo):
                _name = moduleInfo.get("name")
                if _name:
                    self.checkClassMethodsChanged(moduleInfo)
                    for classMethod in moduleInfo["classMethods"]:
                        classMethods = self.pluginConfig["classes"].get(
                            classMethod)
                        if classMethods and _name in classMethods:
                            classMethods.remove(_name)
                            if not classMethods:  # list has become unused
                                del self.pluginConfig["classes"][
                                    classMethod]  # remove class
                    for importModuleInfo in moduleInfo.get(
                            "imports", EMPTYLIST):
                        _removePluginConfigModuleInfo(importModuleInfo)
                    self.pluginConfig["modules"].pop(_name, None)

            _removePluginConfigModuleInfo(moduleInfo)
            if not self.pluginConfig["modules"] and self.pluginConfig[
                    "classes"]:
                self.pluginConfig["classes"].clear()  # clean orphan classes
            self.pluginConfigChanged = True

    def addPluginConfigModuleInfo(self, moduleInfo):
        if self.checkIfImported(moduleInfo):
            return
        name = moduleInfo.get("name")
        self.removePluginConfigModuleInfo(
            name)  # remove any prior entry for this module

        def _addPlugin(moduleInfo):
            _name = moduleInfo.get("name")
            if _name:
                self.modulesWithNewerFileDates.discard(
                    _name)  # no longer has an update available
                self.pluginConfig["modules"][_name] = moduleInfo
                # add classes
                for classMethod in moduleInfo["classMethods"]:
                    classMethods = self.pluginConfig["classes"].setdefault(
                        classMethod, [])
                    if name not in classMethods:
                        classMethods.append(_name)
                self.checkClassMethodsChanged(moduleInfo)
            for importModuleInfo in moduleInfo.get("imports", EMPTYLIST):
                _addPlugin(importModuleInfo)

        _addPlugin(moduleInfo)
        self.pluginConfigChanged = True

    def moduleEnable(self):
        if self.selectedModule in self.pluginConfig["modules"]:
            moduleInfo = self.pluginConfig["modules"][self.selectedModule]
            if self.checkIfImported(moduleInfo):
                return

            def _moduleEnable(moduleInfo):
                if self.moduleEnableButton['text'] == self.ENABLE:
                    moduleInfo["status"] = "enabled"
                elif self.moduleEnableButton['text'] == self.DISABLE:
                    moduleInfo["status"] = "disabled"
                self.checkClassMethodsChanged(moduleInfo)
                for importModuleInfo in moduleInfo.get("imports", EMPTYLIST):
                    _moduleEnable(
                        importModuleInfo)  # set status on nested moduleInfo
                    if importModuleInfo['name'] in self.pluginConfig[
                            "modules"]:  # set status on top level moduleInfo
                        _moduleEnable(self.pluginConfig["modules"][
                            importModuleInfo['name']])

            _moduleEnable(moduleInfo)
            if self.moduleEnableButton['text'] == self.ENABLE:
                self.moduleEnableButton['text'] = self.DISABLE
            elif self.moduleEnableButton['text'] == self.DISABLE:
                self.moduleEnableButton['text'] = self.ENABLE
            self.pluginConfigChanged = True
            self.loadTreeViews()

    def moduleReload(self):
        if self.selectedModule in self.pluginConfig["modules"]:
            url = self.pluginConfig["modules"][self.selectedModule].get(
                "moduleURL")
            if url:
                moduleInfo = PluginManager.moduleModuleInfo(url, reload=True)
                if moduleInfo:
                    if self.checkIfImported(moduleInfo):
                        return
                    self.addPluginConfigModuleInfo(moduleInfo)
                    self.loadTreeViews()
                    self.cntlr.showStatus(_("{0} reloaded").format(
                        moduleInfo["name"]),
                                          clearAfter=5000)
                else:
                    messagebox.showwarning(
                        _("Module error"),
                        _("File or module cannot be reloaded: \n\n{0}").format(
                            url),
                        parent=self)

    def moduleRemove(self):
        if self.selectedModule in self.pluginConfig["modules"]:
            self.removePluginConfigModuleInfo(self.selectedModule)
            self.pluginConfigChanged = True
            self.loadTreeViews()

    def enableAll(self):
        self.enableDisableAll(True)

    def disableAll(self):
        self.enableDisableAll(False)

    def enableDisableAll(self, doEnable):
        for module in self.pluginConfig["modules"]:
            moduleInfo = self.pluginConfig["modules"][module]
            if not moduleInfo.get("isImported"):

                def _enableDisableAll(moduleInfo):
                    if doEnable:
                        moduleInfo["status"] = "enabled"
                    else:
                        moduleInfo["status"] = "disabled"
                    for importModuleInfo in moduleInfo.get(
                            "imports", EMPTYLIST):
                        _enableDisableAll(importModuleInfo)

                _enableDisableAll(moduleInfo)
                if doEnable:
                    self.moduleEnableButton['text'] = self.DISABLE
                else:
                    self.moduleEnableButton['text'] = self.ENABLE
        self.pluginConfigChanged = True
        self.loadTreeViews()
Example #52
0
class autoClicker(Frame):
  
    def __init__(self, parent):
        Frame.__init__(self, parent)   
        self.parent = parent
        self.initUI()
    
    def initUI(self):
        self.sliderTime=0
        self.running = 0
        self.leftclick = 0
        self.middleclick = 0
        self.rightclick = 0
                
        self.parent.overrideredirect(True)
        self.style = Style()
        self.style.theme_use("default")
        self.parent.wm_attributes("-topmost", 1)
        self.parent.resizable(0,0)
        
        self.gripBar = BitmapImage(data=GRIPBAR)
        self.closeBox = BitmapImage(data=CLOSEBOX)
        self.closeHover = BitmapImage(data=CLOSEHOVER)
        self.leftClick = BitmapImage(data=LEFTCLICK)
        self.leftClickDown = BitmapImage(data=LEFTCLICKDOWN)
        self.middleClick = BitmapImage(data=MIDDLECLICK)
        self.middleClickDown = BitmapImage(data=MIDDLECLICKDOWN)
        self.rightClick = BitmapImage(data=RIGHTCLICK)
        self.rightClickDown = BitmapImage(data=RIGHTCLICKDOWN)
        
        self.barFrame = Frame(self)
        self.barFrame.pack(side=TOP, fill=BOTH)
        self.clickFrame = Frame(self, borderwidth=0)
        self.clickFrame.pack(side=TOP, fill=BOTH, padx=12, expand=1)

        self.sliderScale = Scale(self, from_=0, to=1, resolution=.01, orient=HORIZONTAL, borderwidth=0, showvalue=0)
        self.sliderScale.pack(side=TOP, fill="x", expand=1)
        
        self.buttonFrame = Frame(self, borderwidth=0)
        self.buttonFrame.pack(side=TOP, fill=BOTH, expand=1)
        
        self.grip = Label(self.barFrame, image=self.gripBar)
        self.grip.image=self.gripBar
        self.grip.pack(side=LEFT, fill="x")
        self.grip.bind("<ButtonPress-1>", self.startMove)
        self.grip.bind("<ButtonRelease-1>", self.stopMove)
        self.grip.bind("<B1-Motion>", self.onMotion)
        
        self.closeButton = Label(self.barFrame, image=self.closeBox)
        self.closeButton.image=self.closeBox
        self.closeButton.pack(side=RIGHT, fill="none")
        self.closeButton.bind("<ButtonPress-1>", self.sysExit)
        self.closeButton.bind("<Enter>", self.onHover)
        self.closeButton.bind("<Leave>", self.onLeave)
        
        self.leftClickToggle = Label(self.clickFrame, image=self.leftClick, borderwidth=0)
        self.leftClickToggle.image=self.leftClick
        self.leftClickToggle.pack(side=LEFT, expand=1)
        self.leftClickToggle.bind("<Button-1>", self.leftToggle)
        
        self.middleClickToggle = Label(self.clickFrame, image=self.middleClick, borderwidth=0)
        self.middleClickToggle.image=self.middleClick
        self.middleClickToggle.pack(side=LEFT, expand=1)
        self.middleClickToggle.bind("<Button-1>", self.middleToggle)

        self.rightClickToggle = Label(self.clickFrame, image=self.rightClick, borderwidth=0)
        self.rightClickToggle.image=self.rightClick
        self.rightClickToggle.pack(side=LEFT, expand=1)
        self.rightClickToggle.bind("<Button-1>", self.rightToggle)

        self.startButton = Button(self.buttonFrame, text="Start", relief=FLAT, activebackground="lightgrey", borderwidth=0)
        self.startButton.pack(fill=BOTH, expand=1)
        self.startButton.bind("<Button-1>", self.startClick)
        self.startButton.bind("<space>", self.startClick)
                
        w = 116
        h = 74

        ws = self.winfo_screenwidth() # width of the screen
        hs = self.winfo_screenheight() # height of the screen

        x = (ws/2) - (w/2)
        y = (hs/2) - (h/2)

        self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))
        self.parent.config(bg="black")
        self.pack(fill="both", padx=1, pady=1)
        
    def leftToggle(self,event):
        if self.running == 0:
            if self.leftclick == 0:
                event.widget.configure(image=self.leftClickDown)
                self.leftclick = 1;
            else:
                event.widget.configure(image=self.leftClick)
                self.leftclick = 0;
                
    def middleToggle(self,event):
        if self.running == 0:
            if self.middleclick == 0:
                event.widget.configure(image=self.middleClickDown)
                self.middleclick = 1;
            else:
                event.widget.configure(image=self.middleClick)
                self.middleclick = 0;
                
    def rightToggle(self,event):
        if self.running == 0:
            if self.rightclick == 0:
                event.widget.configure(image=self.rightClickDown)
                self.rightclick = 1;
            else:
                event.widget.configure(image=self.rightClick)
                self.rightclick = 0;

    def onHover(self,event):
        event.widget.configure(image=self.closeHover)
    
    def onLeave(self,event):
        event.widget.configure(image=self.closeBox)

    def startMove(self,event):
        self.parent.x = event.x
        self.parent.y = event.y
        
    def onMotion(self, event):
        deltax = event.x - self.parent.x
        deltay = event.y - self.parent.y
        x = self.parent.winfo_x() + deltax
        y = self.parent.winfo_y() + deltay
        self.parent.geometry("+%s+%s" % (x, y))
        
    def stopMove(self, event):
        event.x = None
        event.y = None

    def sysExit(self, event):
        self.running = 0
        sys.exit()
            
    def startClick(self, event):
        if self.running == 0 and not (self.leftclick == 0 and self.middleclick==0 and self.rightclick == 0):
            self.running = 1
            event.widget.config(text="Stop")
            currentMouseX, currentMouseY = pyautogui.position()
            pyautogui.moveTo(currentMouseX, currentMouseY+50)
            threading.Thread(target=self.startLoop, args=()).start()
        else:
            self.running = 0
            event.widget.config(text="Start")
        time.sleep(0.2)
        return

    def startLoop(self):
        while self.running == 1:
            if self.leftclick == 1:
                pyautogui.click()
            if self.middleclick == 1:
                pyautogui.click(button="middle")
            if self.rightclick == 1:
                pyautogui.click(button="right")
            delay = self.sliderScale.get()
            time.sleep(delay)
        return
    def initUI(self):
        """
        Function defines basic layout of whole program.
        """

        # Start instances atributes
        self.master.title("Image Compare")
        self.pack(fill=BOTH, expand=1)
        self.listOfPaths = []
        self.lenght = 0
        self.i = 0
        self.directory1 = "C:\\Plots1"
        self.directory2 = "C:\\Plots2"

        Style().configure("TFrame", background="#333")

        # Defining entrys, lables and text fields
        self.path1 = Entry(self, width=50)
        self.path1.place(x=10, y=10)

        self.path2 = Entry(self, width=50)
        self.path2.place(x=10, y=35)

        self.startFromEntry = Entry(self, width=5)
        self.startFromEntry.place(x=550, y=10)

        self.plot1PathText = Text(self, height=3, width=75)
        self.plot1PathText.place(x=620, y=670)

        self.plot2PathText = Text(self, height=3, width=75)
        self.plot2PathText.place(x=1230, y=670)

        self.lb = Listbox(self, height=15, width=100)
        self.lb.place(x=620, y=740)

        self.numberOfPlotsText = Text(self, height=1, width=5)
        self.numberOfPlotsText.place(x=790, y=10)

        self.currentPlotsText = Text(self, height=1, width=5)
        self.currentPlotsText.place(x=930, y=10)

        numberOfPlotsLabel = Label(self, text="Nuber of plots:")
        numberOfPlotsLabel.place(x=700, y=10)

        currentPlotsLabel = Label(self, text="Current plot:")
        currentPlotsLabel.place(x=850, y=10)

        # Defining buttons
        previousButton = Button(self,
                                text="Previous",
                                command=self.previousButtonFunction)
        previousButton.place(x=10, y=670)

        nextButton = Button(self, text="Next", command=self.nextButtonFunction)
        nextButton.place(x=100, y=670)

        differentButton = Button(self,
                                 text="Different",
                                 command=self.differentButtonFunction)
        differentButton.place(x=300, y=670)

        deleteButton = Button(self,
                              text="Delete",
                              command=self.deleteButtonFunction)
        deleteButton.place(x=380, y=670)

        getPathButton = Button(self,
                               text="Get Path",
                               command=self.get_filepaths)
        getPathButton.place(x=350, y=8)

        startFromButton = Button(self,
                                 text="Start From",
                                 command=self.startFromButtonFunction)
        startFromButton.place(x=600, y=8)
Example #54
0
    def initUI(self):
        self.sliderTime=0
        self.running = 0
        self.leftclick = 0
        self.middleclick = 0
        self.rightclick = 0
                
        self.parent.overrideredirect(True)
        self.style = Style()
        self.style.theme_use("default")
        self.parent.wm_attributes("-topmost", 1)
        self.parent.resizable(0,0)
        
        self.gripBar = BitmapImage(data=GRIPBAR)
        self.closeBox = BitmapImage(data=CLOSEBOX)
        self.closeHover = BitmapImage(data=CLOSEHOVER)
        self.leftClick = BitmapImage(data=LEFTCLICK)
        self.leftClickDown = BitmapImage(data=LEFTCLICKDOWN)
        self.middleClick = BitmapImage(data=MIDDLECLICK)
        self.middleClickDown = BitmapImage(data=MIDDLECLICKDOWN)
        self.rightClick = BitmapImage(data=RIGHTCLICK)
        self.rightClickDown = BitmapImage(data=RIGHTCLICKDOWN)
        
        self.barFrame = Frame(self)
        self.barFrame.pack(side=TOP, fill=BOTH)
        self.clickFrame = Frame(self, borderwidth=0)
        self.clickFrame.pack(side=TOP, fill=BOTH, padx=12, expand=1)

        self.sliderScale = Scale(self, from_=0, to=1, resolution=.01, orient=HORIZONTAL, borderwidth=0, showvalue=0)
        self.sliderScale.pack(side=TOP, fill="x", expand=1)
        
        self.buttonFrame = Frame(self, borderwidth=0)
        self.buttonFrame.pack(side=TOP, fill=BOTH, expand=1)
        
        self.grip = Label(self.barFrame, image=self.gripBar)
        self.grip.image=self.gripBar
        self.grip.pack(side=LEFT, fill="x")
        self.grip.bind("<ButtonPress-1>", self.startMove)
        self.grip.bind("<ButtonRelease-1>", self.stopMove)
        self.grip.bind("<B1-Motion>", self.onMotion)
        
        self.closeButton = Label(self.barFrame, image=self.closeBox)
        self.closeButton.image=self.closeBox
        self.closeButton.pack(side=RIGHT, fill="none")
        self.closeButton.bind("<ButtonPress-1>", self.sysExit)
        self.closeButton.bind("<Enter>", self.onHover)
        self.closeButton.bind("<Leave>", self.onLeave)
        
        self.leftClickToggle = Label(self.clickFrame, image=self.leftClick, borderwidth=0)
        self.leftClickToggle.image=self.leftClick
        self.leftClickToggle.pack(side=LEFT, expand=1)
        self.leftClickToggle.bind("<Button-1>", self.leftToggle)
        
        self.middleClickToggle = Label(self.clickFrame, image=self.middleClick, borderwidth=0)
        self.middleClickToggle.image=self.middleClick
        self.middleClickToggle.pack(side=LEFT, expand=1)
        self.middleClickToggle.bind("<Button-1>", self.middleToggle)

        self.rightClickToggle = Label(self.clickFrame, image=self.rightClick, borderwidth=0)
        self.rightClickToggle.image=self.rightClick
        self.rightClickToggle.pack(side=LEFT, expand=1)
        self.rightClickToggle.bind("<Button-1>", self.rightToggle)

        self.startButton = Button(self.buttonFrame, text="Start", relief=FLAT, activebackground="lightgrey", borderwidth=0)
        self.startButton.pack(fill=BOTH, expand=1)
        self.startButton.bind("<Button-1>", self.startClick)
        self.startButton.bind("<space>", self.startClick)
                
        w = 116
        h = 74

        ws = self.winfo_screenwidth() # width of the screen
        hs = self.winfo_screenheight() # height of the screen

        x = (ws/2) - (w/2)
        y = (hs/2) - (h/2)

        self.parent.geometry('%dx%d+%d+%d' % (w, h, x, y))
        self.parent.config(bg="black")
        self.pack(fill="both", padx=1, pady=1)
Example #55
0
    def initialize_settings_ui(self):
        # Initializes resamples field
        resamples_label = Label(self, text="Resamples (affects recognition accuracy)")
        resamples_label.place(y=12.5, x=12.5)
        resamples_text = tk.StringVar()
        resamples_text.set(self.settings["resamples"])
        resamples_spin = Spinbox(self, from_=1, to=10, textvariable=resamples_text)
        resamples_spin.config(command=partial(self.save_settings, "resamples", lambda: int(resamples_text.get())))
        resamples_spin.place(y=37.5, x=12.5)
        separator1 = Separator(self, orient='horizontal')
        separator1.place(y=62.5, x=12.5, width=375, height=1)

        # Initializes tolerance field
        tolerance_label = Label(self, text="Face matching tolerance (lower is more strict)")
        tolerance_label.place(y=68.75, x=12.5)
        tolerance_text = tk.StringVar()
        tolerance_text.set(self.settings["tolerance"])
        tolerance_spin = Spinbox(self, from_=0, to=1, increment=0.1, textvariable=tolerance_text)
        tolerance_spin.config(command=partial(self.save_settings, "tolerance", lambda: float(tolerance_text.get())))
        tolerance_spin.place(y=93.75, x=12.5)
        separator2 = Separator(self, orient='horizontal')
        separator2.place(y=118.75, x=12.5, width=375, height=1)

        # Initializes track period field
        track_period_label = Label(self, text="Track period (the number of frames between each recognition)")
        track_period_label.place(y=125, x=12.5)
        track_period_text = tk.StringVar()
        track_period_text.set(self.settings["track_period"])
        track_period_spin = Spinbox(self, from_=1, to=30, textvariable=track_period_text)
        track_period_spin.config(command=partial(self.save_settings, "track_period", lambda: int(track_period_text.get())))
        track_period_spin.place(y=150, x=12.5)
        separator3 = Separator(self, orient='horizontal')
        separator3.place(y=175, x=12.5, width=375, height=1)

        # Initializes blur method field
        blur_method_label = Label(self, text="Blur method")
        blur_method_label.place(y=181.25, x=12.5)
        blur_method_text = tk.StringVar()
        blur_method_text.set(self.settings["blur_method"])
        blur_method_menu = Combobox(self, textvariable=blur_method_text, values=("pixelate", "blur", "blacken"))
        blur_method_text.trace('w', partial(self.save_settings, "blur_method", lambda: blur_method_text.get()))
        blur_method_menu.place(y=206.25, x=12.5)
        separator4 = Separator(self, orient='horizontal')
        separator4.place(y=231.25, x=12.5, width=375, height=1)

        # Initializes blur intensity field
        blur_intensity_label = Label(self, text="Blur intensity (filter size)")
        blur_intensity_label.place(y=237.5, x=12.5)
        blur_intensity_text = tk.StringVar()
        blur_intensity_text.set(self.settings["blur_intensity"])
        blur_intensity_spin = Spinbox(self, from_=1, to=30, textvariable=blur_intensity_text)
        blur_intensity_spin.config(command=partial(self.save_settings, "blur_intensity", lambda: int(blur_intensity_text.get())))
        blur_intensity_spin.place(y=262.5, x=12.5)
        separator5 = Separator(self, orient='horizontal')
        separator5.place(y=287.5, x=12.5, width=375, height=1)

        # Initializes display output field
        display_output_flag = tk.IntVar()
        display_output_flag.set(self.settings["display_output"])
        display_output_checkbox = tk.Checkbutton(self, text='Display output', variable=display_output_flag, onvalue=1, offvalue=0)
        display_output_checkbox.config(command=partial(self.save_settings, "display_output", lambda: display_output_flag.get()))
        display_output_checkbox.place(y=293.75, x=12.5)
Example #56
0
    def __init__(self, parent, txt=dict()):
        """Instanciating the output workbook."""
        self.parent = parent
        Frame.__init__(self)

        # subframe
        self.FrDb = Labelframe(self,
                               name="database",
                               text=txt.get("gui_fr2", "SGBD"))

        # DB variables
        self.opt_pgvw = IntVar(self.FrDb)  # able/disable PostGIS views
        self.host = StringVar(self.FrDb, "localhost")
        self.port = IntVar(self.FrDb, 5432)
        self.dbnb = StringVar(self.FrDb)
        self.user = StringVar(self.FrDb, "postgres")
        self.pswd = StringVar(self.FrDb)

        # Form widgets
        self.ent_H = Entry(self.FrDb, textvariable=self.host)
        self.ent_P = Entry(self.FrDb, textvariable=self.port, width=5)
        self.ent_D = Entry(self.FrDb, textvariable=self.dbnb)
        self.ent_U = Entry(self.FrDb, textvariable=self.user)
        self.ent_M = Entry(self.FrDb, textvariable=self.pswd, show="*")

        caz_pgvw = Checkbutton(
            self.FrDb,
            text=txt.get("gui_views", "Views enabled"),
            variable=self.opt_pgvw,
        )

        # Label widgets
        self.lb_H = Label(self.FrDb, text=txt.get("gui_host", "Host"))
        self.lb_P = Label(self.FrDb, text=txt.get("gui_port", "Port"))
        self.lb_D = Label(self.FrDb, text=txt.get("gui_db", "Database"))
        self.lb_U = Label(self.FrDb, text=txt.get("gui_user", "User"))
        self.lb_M = Label(self.FrDb, text=txt.get("gui_mdp", "Password"))
        # widgets placement
        self.ent_H.grid(row=1,
                        column=1,
                        columnspan=2,
                        sticky="NSEW",
                        padx=2,
                        pady=2)
        self.ent_P.grid(row=1,
                        column=3,
                        columnspan=1,
                        sticky="NSE",
                        padx=2,
                        pady=2)
        self.ent_D.grid(row=2,
                        column=1,
                        columnspan=1,
                        sticky="NSEW",
                        padx=2,
                        pady=2)
        self.ent_U.grid(row=2,
                        column=3,
                        columnspan=1,
                        sticky="NSEW",
                        padx=2,
                        pady=2)
        self.ent_M.grid(row=3,
                        column=1,
                        columnspan=3,
                        sticky="NSEW",
                        padx=2,
                        pady=2)
        self.lb_H.grid(row=1, column=0, sticky="NSEW", padx=2, pady=2)
        self.lb_P.grid(row=1, column=3, sticky="NSW", padx=2, pady=2)
        self.lb_D.grid(row=2, column=0, sticky="NSW", padx=2, pady=2)
        self.lb_U.grid(row=2, column=2, sticky="NSW", padx=2, pady=2)
        self.lb_M.grid(row=3, column=0, sticky="NSWE", padx=2, pady=2)
        caz_pgvw.grid(row=4, column=0, sticky="NSWE", padx=2, pady=2)

        # frame position
        self.FrDb.grid(row=3, column=1, sticky="NSWE", padx=2, pady=2)
Example #57
0
    def __startInput(self) -> None:
        # called setup in java
        if self.__title is not None:
            self.__root.title(self.__title)
        if self.__imagePath is not None:
            self.__root.iconphoto(True, PhotoImage(file=self.__imagePath))

        self.__root.configure(bg=self.__bgColor)
        Grid.rowconfigure(self.__root, max(self.__colRowCount), weight=1)
        Grid.columnconfigure(self.__root, 3, weight=1)
        Grid.columnconfigure(self.__root, 1, weight=1)
        Grid.columnconfigure(self.__root, 2, weight=1)

        for label in list(self.__printWindow.keys()):
            frame = Frame(self.__root)
            pw = self.__printWindow[label]
            pw['Text'] = Text(frame, wrap="word")
            pw['Scroll'] = Scrollbar(
                frame, command=pw['Text'].yview, orient="vertical")
            pw['Text'].config(state="disabled",
                              yscrollcommand=pw['Scroll'].set)
            pw['Scroll'].pack(side="right", fill="y")
            pw['Text'].pack(side="left", fill="both", expand="yes")
            frame.grid(sticky="NSEW", row=max(self.__colRowCount), column=pw['startCol'], padx=5, pady=5,
                       columnspan=(pw['endCol'] - pw['startCol'] + 1))
            Grid.rowconfigure(self.__root, max(self.__colRowCount), weight=1)
            for i in range(len(self.__colRowCount)):
                self.__colRowCount[i] += 1

        for p in self.__prompts.keys():
            self.__prompts[p]['Entry'] = Label(
                self.__root, text=self.__prompts[p]['prompt'])
            self.__prompts[p]['Entry'].grid(sticky="W" if self.__prompts[p]['alignLeft'] else 'E',
                                            row=self.__prompts[p]['row'], column=self.__prompts[p]['col'], padx=5,
                                            pady=5)

        # write out spacers in grid
        for index in range(len(self.__spacers)):
            s = self.__spacers[index]
            Label(self.__root, background=self.__bgColor).grid(
                row=s['row'], column=s['col'], padx=0, pady=5, ipady='1m')

        for sortedLabel in self.__getSortedLabels():
            label = self.__inputs[sortedLabel]
            if label['type'] == 'combo':
                label['Entry'] = Combobox(
                    self.__root, values=label['initValue'], state="readonly")
                label['Entry'].current(0)
                label['Entry'].grid(
                    sticky='EW', row=label['row'], column=label['col'], padx=5, pady=5)
            elif label['type'] == 'readstring':
                prompt = Label(self.__root, text="No file selected.")
                prompt.grid(sticky="W", row=self.__fileSelections[sortedLabel]['row'], column=2, padx=5,
                                                pady=5)
                self.__fileSelections[sortedLabel]['entry'] = prompt
            else:
                # verify command
                vcmd = (self.__root.register(self.__validateFloat), '%P') if label['type'] == 'float' else (
                    self.__root.register(self.__validateInt), '%P') if label['type'] == 'int' else None
                label['Entry'] = Entry(
                    self.__root, validate='key', validatecommand=vcmd, width=23)
                label['Entry'].grid(
                    sticky='EW', row=label['row'], column=label['col'], padx=5, pady=5)
                label['Entry'].insert(0, label['value'])

        for funcLabel in self.__functions:
            label = self.__functions[funcLabel]
            label['Button'] = Button(self.__root, takefocus=1, text=funcLabel,
                                     name=funcLabel[0].lower() + funcLabel[1:])
            label['Button'].grid(
                padx=5, pady=5, ipady='1m', sticky="NSEW", row=label['row'], column=label['col'])
            if 'function' not in label:
                label['Button'].bind("<Return>", self.__getFileName)
                label['Button'].bind("<Button-1>", self.__getFileName)
            else:
                label['Button'].bind("<Return>", self.__buttonPressed)
                label['Button'].bind("<Button-1>", self.__buttonPressed)

        # Refresh the input if the window is closed out
        self.__root.protocol("WM_DELETE_WINDOW", lambda: (
            self.__refreshInput(), self.__root.destroy()))
        self.__root.mainloop()
        try:
            self.__root.destroy()
        except TclError:
            # usually in the case of user closing the window
            pass
Example #58
0
class SignInView(Frame):
    def __init__(self, master):
        super().__init__(master=master)
        self.layout_components()
        # Setup Callbacks
        self.show_register: Callable = None
        self.sign_in: Callable = None
        self.user_Entry.focus()

    def layout_components(self):
        self.pack(fill=tk.BOTH, expand=False, padx=PADX, pady=PADY)
        error_font = font.Font(family="Ariel", size=8)

        # Variables
        self.username = tk.StringVar()
        self.username.set("")

        self.password = tk.StringVar()
        self.password.set("")

        # Username Row
        user_Frame = Frame(self)
        user_Frame.pack(fill=tk.X)
        user_Label = Label(user_Frame, text="Username:"******"<FocusOut>", self.enable_sign_in)
        self.user_Entry.pack(fill=tk.X, padx=PADX, pady=PADY, expand=True)

        # Password Row
        pass_Frame = Frame(self)
        pass_Frame.pack(fill=tk.X)
        pass_Label = Label(pass_Frame, text="Password:"******"*")
        self.pass_Entry.bind("<FocusOut>", self.enable_sign_in)
        self.pass_Entry.pack(fill=tk.X, padx=PADX, pady=PADY, expand=True)

        # Error Row
        err_Frame = Frame(self)
        err_Frame.pack(fill=tk.X)
        self.err_Label = Label(err_Frame,
                               text="",
                               foreground="red",
                               font=error_font)
        self.err_Label.pack(side=tk.LEFT,
                            anchor="center",
                            expand=True,
                            padx=PADX,
                            pady=PADY)

        # Button Row
        button_Frame = Frame(self)
        button_Frame.pack(fill=tk.X)
        # Cancel Button
        cncl_Button = Button(button_Frame, text="Cancel", command=self.cancel)
        cncl_Button.pack(side=tk.RIGHT, padx=PADX, pady=PADY, expand=False)
        # Sign in Button
        self.sgnn_Button = Button(button_Frame,
                                  text="Sign in",
                                  state="disabled",
                                  command=self._sign_in)
        self.sgnn_Button.pack(side=tk.RIGHT,
                              padx=PADX,
                              pady=PADY,
                              expand=False)

        # Register Row
        register_Frame = Frame(self)
        register_Frame.pack(fill=tk.X)
        register_Button = Button(register_Frame,
                                 text="Register",
                                 command=self._show_register)
        register_Button.pack(side=tk.RIGHT, padx=PADX, pady=PADY, expand=False)
        register_Label = Label(register_Frame,
                               text="Not a Member of ExchangeGram?")
        register_Label.pack(side=tk.RIGHT, padx=PADX, pady=PADY)

    def _sign_in(self):
        if self.sign_in is not None:
            self.sign_in()

    def enable_sign_in(self, event):
        if self.username.get() != "" and self.password.get() != "":
            self.sgnn_Button.configure(state="normal")
        else:
            self.sgnn_Button.configure(state="disabled")

    def failed_sign_in(self):
        self.err_Label.configure(text="Username/Password Incorrect")

    def cancel(self):
        self.username.set("")
        self.password.set("")
        self.user_Entry.focus()

    def _show_register(self):
        if self.show_register is not None:
            self.cancel()
            self.show_register()
        else:
            pass
Example #59
0
    def initUI(self):

        self.parent.title("Calculate Mavlink UAV->GCS telemetry datarate")
        self.pack(fill=BOTH, expand=1)

        count = 0
        count_frame = 0
        count_row = 0
        for frame_name in mavlink_streams_list:
            child_frame = Frame(self, borderwidth=2, relief=RIDGE)
            child_frame.grid(row=count_row, column=count_frame % self.columns)
            if (count_frame % self.columns == self.columns - 1):
                count_row = count_row + 1
            count_frame = count_frame + 1

            frame_label = Label(child_frame,
                                text=frame_name[0] + " message stream")
            frame_label.pack(side=TOP)

            self.streamrate_name_array[frame_name[0]] = {}
            self.streamrate_cb_array[frame_name[0]] = {}

            comboFrame = Frame(child_frame)
            comboFrame.pack(side=LEFT)
            for frame_boxes in frame_name[2]:

                comboframe = Frame(comboFrame)
                comboframe.pack(side=TOP)

                combo = Combobox(
                    comboframe,
                    values=tuple(
                        mavlink_msg_temp
                        for mavlink_msg_temp in mavlink_message_lengths_dict))
                combo.grid(row=count, column=0)
                index = list(mavlink_message_lengths_dict.keys()).index(
                    frame_boxes[0])
                combo.current(index)

                var = IntVar()
                if (frame_boxes[1]):
                    var.set(1)
                else:
                    var.set(0)
                checkbox = Checkbutton(comboframe,
                                       variable=var,
                                       command=self.updateCombo)
                checkbox.grid(row=count, column=1)

                self.streamrate_name_array[frame_name[0]][
                    frame_boxes[0]] = combo
                self.streamrate_cb_array[frame_name[0]][frame_boxes[0]] = var

                combo.bind("<<ComboboxSelected>>", self.updateCombo)
                count = count + 1

            streamrate_frame = Frame(child_frame)
            streamrate_frame.pack(side=TOP, anchor=CENTER)
            data_rate_label = Label(streamrate_frame, text="Stream Rate")
            data_rate_label.pack()

            self.data_rate_edit = Entry(streamrate_frame, width=2)
            self.data_rate_edit.insert(0, frame_name[1])
            self.streamrate_edit_array[frame_name[0]] = self.data_rate_edit
            self.data_rate_edit.pack(side=LEFT, anchor=CENTER)

            unit_Label = Label(streamrate_frame, text="Hz")
            unit_Label.pack(side=RIGHT, anchor=CENTER)

            datarate_frame = Frame(child_frame)
            datarate_frame.pack(side=TOP, anchor=CENTER)
            total_data_rate_label = Label(datarate_frame, text="Data Rate")
            total_data_rate_label.pack(side=TOP, anchor=CENTER)
            self.total_data_rate_answer = Label(datarate_frame,
                                                text="   bits/s")
            self.total_data_rate_answer.pack(side=TOP, anchor=CENTER)
            self.streamDataRate_array[
                frame_name[0]] = self.total_data_rate_answer

        self.end_total_data_rate_label = Label(self.parent,
                                               text="Total Data Rate")
        self.end_total_data_rate_label.pack(side=TOP)
Example #60
0
class MainWindow(Frame):
    def __init__(self, parent):

        Frame.__init__(self, parent)
        self.parent = parent
        self.streamrate_name_array = {}
        self.streamrate_cb_array = {}
        self.streamDataRate_array = {}
        self.streamrate_edit_array = {}
        # you can change this one to make the GUI wider
        self.columns = 3
        self.initUI()

        self.parent.bind('<Return>', self.updateCombo)
        self.updateCombo()

    def updateCombo(self, event=None):
        totalBits = 0
        for frame_name in mavlink_streams_list:
            bits = 0
            for frame_boxes in frame_name[2]:
                temp = self.streamrate_name_array[frame_name[0]][
                    frame_boxes[0]].get()
                if (self.streamrate_cb_array[frame_name[0]][
                        frame_boxes[0]].get()):
                    bits = bits + (
                        8 * mavlink_message_lengths_dict[temp]
                    )  # convert number of bytes to number of bits
            datarate = float(self.streamrate_edit_array[frame_name[0]].get())
            tempDataBits = int(bits * datarate)
            self.streamDataRate_array[frame_name[0]].config(
                text=str(tempDataBits) + " bits/s")
            totalBits = int(totalBits + tempDataBits)
        self.end_total_data_rate_label.config(text="Total Data Rate is " +
                                              str(totalBits) + " bits/s")

    def initUI(self):

        self.parent.title("Calculate Mavlink UAV->GCS telemetry datarate")
        self.pack(fill=BOTH, expand=1)

        count = 0
        count_frame = 0
        count_row = 0
        for frame_name in mavlink_streams_list:
            child_frame = Frame(self, borderwidth=2, relief=RIDGE)
            child_frame.grid(row=count_row, column=count_frame % self.columns)
            if (count_frame % self.columns == self.columns - 1):
                count_row = count_row + 1
            count_frame = count_frame + 1

            frame_label = Label(child_frame,
                                text=frame_name[0] + " message stream")
            frame_label.pack(side=TOP)

            self.streamrate_name_array[frame_name[0]] = {}
            self.streamrate_cb_array[frame_name[0]] = {}

            comboFrame = Frame(child_frame)
            comboFrame.pack(side=LEFT)
            for frame_boxes in frame_name[2]:

                comboframe = Frame(comboFrame)
                comboframe.pack(side=TOP)

                combo = Combobox(
                    comboframe,
                    values=tuple(
                        mavlink_msg_temp
                        for mavlink_msg_temp in mavlink_message_lengths_dict))
                combo.grid(row=count, column=0)
                index = list(mavlink_message_lengths_dict.keys()).index(
                    frame_boxes[0])
                combo.current(index)

                var = IntVar()
                if (frame_boxes[1]):
                    var.set(1)
                else:
                    var.set(0)
                checkbox = Checkbutton(comboframe,
                                       variable=var,
                                       command=self.updateCombo)
                checkbox.grid(row=count, column=1)

                self.streamrate_name_array[frame_name[0]][
                    frame_boxes[0]] = combo
                self.streamrate_cb_array[frame_name[0]][frame_boxes[0]] = var

                combo.bind("<<ComboboxSelected>>", self.updateCombo)
                count = count + 1

            streamrate_frame = Frame(child_frame)
            streamrate_frame.pack(side=TOP, anchor=CENTER)
            data_rate_label = Label(streamrate_frame, text="Stream Rate")
            data_rate_label.pack()

            self.data_rate_edit = Entry(streamrate_frame, width=2)
            self.data_rate_edit.insert(0, frame_name[1])
            self.streamrate_edit_array[frame_name[0]] = self.data_rate_edit
            self.data_rate_edit.pack(side=LEFT, anchor=CENTER)

            unit_Label = Label(streamrate_frame, text="Hz")
            unit_Label.pack(side=RIGHT, anchor=CENTER)

            datarate_frame = Frame(child_frame)
            datarate_frame.pack(side=TOP, anchor=CENTER)
            total_data_rate_label = Label(datarate_frame, text="Data Rate")
            total_data_rate_label.pack(side=TOP, anchor=CENTER)
            self.total_data_rate_answer = Label(datarate_frame,
                                                text="   bits/s")
            self.total_data_rate_answer.pack(side=TOP, anchor=CENTER)
            self.streamDataRate_array[
                frame_name[0]] = self.total_data_rate_answer

        self.end_total_data_rate_label = Label(self.parent,
                                               text="Total Data Rate")
        self.end_total_data_rate_label.pack(side=TOP)