Exemple #1
0
class Application(Tk):
    """Glavni prozor aplikacije, fiksne velicine 800x600, sadrzi container u kome se kasnije smenjuju razni Frame-ovi"""
    def __init__(self, *args, **kwargs):
        """Konstruktor klase Application, postavlja naslov, velicinu i default font prozora. Kreira container i
        postavlja ga u prozoru. Preko tog containera ce se kasnije smenjivati razni Frame-ovi.
        Na kraju poziva funkciju show_frame i postavlja PocetniFrame u containeru."""
        Tk.__init__(self, *args, **kwargs)

        Tk.title(self, "Santorini")
        Tk.geometry(self, "800x600")
        Tk.resizable(self, 0, 0)
        Tk.option_add(self, "*Font", "Arial 16 bold")

        self.container = Frame(self)
        self.container.pack(side="top", fill='both', expand=1)
        self.container.grid_rowconfigure(0, weight=1)
        self.container.grid_columnconfigure(0, weight=1)

        self.show_frame(PocetniFrame)

    def show_frame(self, cont, *args, **kwarg):
        """Instancira frame koji dobije kao parametar i postavlja ga u container.
        
        :param cont: Frame koji treba prikazati u containeru
        :type cont: Frame
        """
        frame = cont(self.container, self, *args, **kwarg)
        frame.grid(row=0, column=0, sticky="nsew")
        frame.tkraise()
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)
        '''
            the container is where we'll stack a bunch of frames
            on top of each other, then the one we want visible
            will be raised above the others
        '''
        container = Frame(self)
        container.pack(side='top', fill='both', expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}
        for F in (LoginPage, MenuPage, FacebookPage, TwitterPage,
                  FacebookPublicPage, FacebookPrivatePage):
            page_name = F.__name__
            frame = F(parent=container, controller=self)
            self.frames[page_name] = frame
            '''
                put all of the pages in the same location;
                the one on the top of the stacking order
                will be the one that is visible.
            '''
            frame.grid(row=0, column=0, sticky='nsew')

        self.show_frame('LoginPage')
Exemple #3
0
    def home_page(self, master):
        frame = Frame(master)
        frame.grid(row=0, column=0)

        image = PhotoImage(file="img/guido.gif")
        bg = Label(frame, image=image)
        bg.image = image
        bg.grid(row=0, column=0, rowspan=4, columnspan=2)

        index = 0
        while index < 3:
            frame.grid_columnconfigure(index, minsize=200)
            frame.grid_rowconfigure(index, minsize=80)
            index += 1

        summary_button = HomeButton(frame, self.to_summary, 'img/summary.png')
        summary_button.grid(row=0, column=0, sticky='w')

        edit_button = HomeButton(frame, self.to_edit, 'img/edit.png')
        edit_button.grid(row=0, column=1, sticky='e')

        momentary_button = HomeButton(frame, self.to_momentary, 'img/momentary.png')
        momentary_button.grid(row=1, column=0, sticky='w')

        preferences_button = HomeButton(frame, self.to_pref, 'img/preferences.png')
        preferences_button.grid(row=1, column=1, sticky='e')

        music = HomeButton(frame, self.to_summary, 'img/music.png')
        music.grid(row=2, column=0, sticky='w')

        info = HomeButton(frame, self.to_summary, 'img/info.png')
        info.grid(row=2, column=1, sticky='e')

        return frame
Exemple #4
0
    def __init__(self, *main):
        Tk.__init__(self, *main)
        container = Frame(self)
        container.pack(side="top", expand=True)

        container.grid_rowconfigure(0,
                                    weight=1)  ### allows for frames to expand
        container.grid_columnconfigure(0, weight=1)

        self.fileAddress = ""  ## creates the variable which will be used fo the main functions to plot/forecast

        self.frames = {
        }  #### creates dictionary to store alll frames which willl be used
        pages = (MainMenu, Op1, Op2, Op3, Op4, FileSelection
                 )  ### list with all frames
        for i in (
                pages
        ):  ##for loop to allow all pages to inherit methods from main class

            frame = i(container, self)

            self.frames[
                i] = frame  #### allows frames to inherit characteristics of the main class and hence use its methods

            frame.grid(row=0, column=0, sticky="nsew")  #
            frame.grid_rowconfigure(0, minsize=8, weight=1)
            frame.grid_columnconfigure(0, minsize=8, weight=1)
            frame.grid_propagate(False)
    def __init__(self, master, cnf={}, **kw):
        super().__init__(master, cnf, **kw)

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

        frame = Frame(self, borderwidth=2, relief="raised")
        frame.grid(row=1, column=1, sticky="nsew")
        frame.grid_rowconfigure(0, weight=4)
        frame.grid_rowconfigure(1, weight=2)
        frame.grid_rowconfigure(2, weight=1)
        frame.grid_columnconfigure(0, weight=1)
        frame.grid_columnconfigure(1, weight=1)

        google_contacts_image = Label(frame, image=load_image(self, "person.png", RelativeSize.big))
        google_contacts_image.grid(row=0, column=0, columnspan=2, sticky="nsew")

        self.caller_id_text = StringVar(value="caller_id_text")

        caller_id_label = Label(frame, textvariable=self.caller_id_text, font=load_font(RelativeSize.big))
        caller_id_label.grid(row=1, column=0, columnspan=2, sticky="n")

        self.answer_button = Button(frame, image=load_image(self, "call.png"), relief="flat")
        self.answer_button.grid(row=2, column=0, sticky="nsew")

        self.decline_button = Button(frame, image=load_image(self, "hangup.png"), relief="flat")
        self.decline_button.grid(row=2, column=1, sticky="nsew")
Exemple #6
0
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)

        Tk.wm_title(self, "bOOk!nG.CoM")
        Tk.iconbitmap(self, "logo.ico")

        container = Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        menubar = Menu(container)
        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label="Home",
                             command=lambda: self.show_frame(StartPage))
        filemenu.add_separator()
        filemenu.add_command(label="Exit", command=quit)
        menubar.add_cascade(label="File", menu=filemenu)
        Tk.config(self, menu=menubar)

        self.frames = {}

        for F in (StartPage, RegisterPage, LoginPage, WelcomePage):
            frame = F(container, self)
            self.frames[F] = frame
            frame.grid(row=0, column=0, sticky="nsew")
        self.show_frame(StartPage)
Exemple #7
0
    def __init__(self):
        """
        Initialise the class
        """
        Tk.__init__(self)

        self.title('WLLR footplate crew rostering program')
        self.geometry('850x600+250+100')
        self.frame_names_list = (HomeScreen, BlankAvailabilityScreen,
                                 BlankRosterScreen, AllocateCrewsScreen,
                                 MasterAvailabilityScreen,
                                 IndividualRostersScreen, ErrorScreen,
                                 ErrorScreenExport, WaitScreen)
        self.frames = {}
        self.background_col = 'black'
        self.foreground_col = 'white'
        self.font = 'courier 11'

        # the container holds the stack of frames on top of each other. The one to be visible will be raised above the others
        container = Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        # Create each frame instance and add to self.frames dictionary
        for frame_name in self.frame_names_list:
            page_name = frame_name.__name__
            frame_object = frame_name(parent=container,
                                      controller=self,
                                      background_col=self.background_col,
                                      foreground_col=self.foreground_col,
                                      font=self.font)
            self.frames[page_name] = frame_object
            frame_object.grid(row=0, column=0, sticky="nsew")
        self.show_frame(HomeScreen.__name__)
Exemple #8
0
    def create_instance_panel(self):
        frm_inst = Frame(self.ntbk)
        frm_inst.grid_columnconfigure(0, weight=1)
        frm_inst.grid_rowconfigure(0, weight=1)
        frm_inst.grid_columnconfigure(1, weight=3)
        frm_inst.grid_rowconfigure(1, weight=0)
        self.instance_list = Listbox(frm_inst, width=20)
        self.instance_list.bind('<<ListboxSelect>>', self.select_instance)
        self.instance_list.pack()
        self.instance_list.grid(row=0, column=0, sticky=(N, S, W, E))

        self.instance_txt = Text(frm_inst, width=75)
        self.instance_txt.grid(row=0, column=1, rowspan=2, sticky=(N, S, W, E))
        self.instance_txt.config(state=DISABLED)

        self.btninstframe = Frame(frm_inst, bd=1)
        self.btninstframe.grid(row=1, column=0, columnspan=1)
        self.btninstframe.grid_columnconfigure(0, weight=1)
        Button(self.btninstframe, text=ugettext("Launch"), width=25, command=self.open_inst).grid(
            row=0, column=0, columnspan=2, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Modify"), width=10,
               command=self.modify_inst).grid(row=1, column=0, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Delete"), width=10,
               command=self.delete_inst).grid(row=1, column=1, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Save"), width=10,
               command=self.save_inst).grid(row=2, column=0, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Restore"), width=10,
               command=self.restore_inst).grid(row=2, column=1, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Add"), width=25, command=self.add_inst).grid(
            row=3, column=0, columnspan=2, sticky=(N, S))

        self.ntbk.add(frm_inst, text=ugettext('Instances'))
Exemple #9
0
    def __init__(self, master, cnf={}, **kw):
        super().__init__(master, cnf, **kw)

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

        frame = Frame(self, borderwidth=2, relief="raised")
        frame.grid(row=1, column=1, sticky="nsew")
        frame.grid_rowconfigure(0, weight=2)
        frame.grid_rowconfigure(1, weight=1)
        frame.grid_rowconfigure(2, weight=1)
        frame.grid_rowconfigure(3, weight=2)
        frame.grid_columnconfigure(0, weight=1)

        error_image = Label(frame,
                            image=load_image(self, "error.png",
                                             RelativeSize.big))
        error_image.grid(row=0, column=0, sticky="sew")

        self.error_title = Label(frame, font=load_font(RelativeSize.big))
        self.error_title.grid(row=1, column=0)

        self.error_detail = Label(frame)
        self.error_detail.grid(row=2, column=0)
Exemple #10
0
    def create_instance_panel(self):
        frm_inst = Frame(self.ntbk)
        frm_inst.grid_columnconfigure(0, weight=1)
        frm_inst.grid_rowconfigure(0, weight=1)
        frm_inst.grid_columnconfigure(1, weight=3)
        frm_inst.grid_rowconfigure(1, weight=0)
        self.instance_list = Listbox(frm_inst, width=20)
        self.instance_list.bind('<<ListboxSelect>>', self.select_instance)
        self.instance_list.pack()
        self.instance_list.grid(row=0, column=0, sticky=(N, S, W, E))

        self.instance_txt = Text(frm_inst, width=75)
        self.instance_txt.grid(row=0, column=1, rowspan=2, sticky=(N, S, W, E))
        self.instance_txt.config(state=DISABLED)

        self.btninstframe = Frame(frm_inst, bd=1)
        self.btninstframe.grid(row=1, column=0, columnspan=1)
        self.btninstframe.grid_columnconfigure(0, weight=1)
        Button(self.btninstframe, text=ugettext("Launch"), width=25, command=self.open_inst).grid(
            row=0, column=0, columnspan=2, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Modify"), width=10,
               command=self.modify_inst).grid(row=1, column=0, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Delete"), width=10,
               command=self.delete_inst).grid(row=1, column=1, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Save"), width=10,
               command=self.save_inst).grid(row=2, column=0, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Restore"), width=10,
               command=self.restore_inst).grid(row=2, column=1, sticky=(N, S))
        Button(self.btninstframe, text=ugettext("Add"), width=25, command=self.add_inst).grid(
            row=3, column=0, columnspan=2, sticky=(N, S))

        self.ntbk.add(frm_inst, text=ugettext('Instances'))
 def open_pop(self, hook_remove, hook_add, hook_apply):
     '''Manage bookmark sources: Major dialogue'''
     dprint(3, "\nTkMemobook::open_pop:: ")
     manager = Toplevel(self.root)
     manager_list = ListboxHV(manager, selectmode="multiple")
     manager_items = self.ctrl["db"]["scan"]
     if isinstance(manager_items, str):
         manager_items = [ manager_items ]
     else:
         manager_items = list(manager_items)
     manager_items.sort()
     for item in manager_items:
         manager_list.insert(END, item)
     manager_list.grid_columnconfigure(0, weight=1)
     manager_list.grid_rowconfigure(0, weight=1)
     manager_list.grid(sticky="nswe")
     buttons = Frame(manager)
     rembutt = Button(buttons,
                      text="Remove",
                      command=lambda: hook_remove(manager_list, manager_items) )
     addbutt = Button(buttons,
                      text="Add Other...",
                      command=lambda: hook_add(manager, manager_list, manager_items) )
     appbutt = Button(buttons,
                      text="Apply",
                      command=lambda: self.__get_busy_with(None, hook_apply, manager, manager_items) )
     rembutt.grid(row=1, column=0)
     addbutt.grid(row=1, column=1)
     appbutt.grid(row=1, column=2)
     buttons.grid_columnconfigure(1, weight=1)
     buttons.grid_rowconfigure(1, weight=1)
     buttons.grid(stick="nswe")
     manager.grid_columnconfigure(0, weight=1)
     manager.grid_rowconfigure(0, weight=1)
class App(Tk):
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)
        # Setup Menu
        MainMenu(self)

        self.container = Frame(self)
        self.container.pack(side="top", fill="both", expand=True)
        self.container.grid_rowconfigure(0, weight=1)
        self.container.grid_columnconfigure(0, weight=1)

        self.frames = {}

        for F in (TextBraillePage, BrailleTextPage):
            frame = F(self.container, self)
            self.frames[F] = frame
            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame(TextBraillePage)

    def show_frame(self, context):
        if context == TextBraillePage:
            self.title("Text to Braille")
        elif context == BrailleTextPage:
            self.title("Braille to Text")
        frame = self.frames[context]
        frame.tkraise()
    def __init__(self,
                 file_name,
                 task=None,
                 doc_id=None,
                 only_reads=True,
                 *args,
                 **kwargs):
        Tk.__init__(self, *args, **kwargs)
        Tk.wm_title(self, "Document Tracker Analyser")
        self.style = Style()
        self.data_loader = DataLoader(file_name, only_reads=only_reads)
        container = Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}
        self.setup_pages(container)

        self.show_frame(NavigationPage)

        if task == '2':
            try:
                self.show_graph_page(self.data_loader.documents[doc_id])
            except KeyError:
                print("Invalid document UUI: " + doc_id)
                sys.exit(2)
        elif task == '3a':
            self.show_graph_page_browser(
                self.data_loader.get_views_by_browser_global_base())
        elif task == '3b':
            self.show_graph_page_browser(
                self.data_loader.get_views_by_browser_global())
    def __init__(self):
        """
        Initialise the class
        """
        Tk.__init__(self)

        self.title('WLLR timetable diagram program')
        self.geometry('850x600+250+100')
        self.frame_names_list = (HomeScreen,GraphTest)
        self.frames = {}
        self.background_col = 'black'
        self.foreground_col = 'white'
        self.font = 'courier 11'

        # the container holds the stack of frames on top of each other. The one to be visible will be raised above the others
        container = Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        # Create each frame instance and add to self.frames dictionary
        for frame_name in self.frame_names_list:
            page_name = frame_name.__name__
            frame_object = frame_name(parent=container, controller=self, background_col = self.background_col, foreground_col = self.foreground_col, font = self.font)
            self.frames[page_name] = frame_object
            frame_object.grid(row=0, column=0, sticky="nsew")
        self.show_frame(HomeScreen.__name__)
Exemple #15
0
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)

        # defining font types before creating the frames.
        self.title_font = tkfont.Font(family=HELVETICA, size=30, weight=BOLD)
        self.normal_font = tkfont.Font(family=FIXEDSYS, size=16)

        # the container is where we'll stack a bunch of frames on top of each other, then the one we want visible will
        # be raised above the others.
        container = Frame(self)
        # makes the container to spread on all over the window even if it's resized. don't know what the fields do.
        container.pack(side=TOP, fill=BOTH, expand=True)
        # if there's a space, it will be filled by the container.
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        # dictionary that contains all the frames
        self.frames = {}
        # creating all the frames, and write them to the dictionary.
        for F in (LogoScreen, StartScreen, SignupScreen, LoginScreen,
                  HomeScreen, EditProfileScreen, CreateProjectScreen):
            page_name = F.__name__
            frame = F(parent=container, controller=self)
            self.frames[page_name] = frame
            # put all of the pages in the same location; the one on the top of the stacking order will be the one that
            # is visible.
            frame.grid(row=0, column=0, sticky=NSEW)
        UpdateHomePage(self.frames[HOME_SCREEN]).start()
        self.show_frame(LOGO_SCREEN)
Exemple #16
0
class ScrolledText(Text):
    def __init__(self, master=None, **kw):
        self.frame = Frame(master)
        self.vbar = AutoScrollbar(self.frame, orient="vertical")
        self.vbar.grid(row=0, column=1, sticky="ns")
        self.frame.grid_columnconfigure(0, weight=1)
        self.frame.grid_columnconfigure(1, weight=0)
        self.frame.grid_rowconfigure(0, weight=1)

        kw.update({'yscrollcommand': self.vbar.set})
        Text.__init__(self, self.frame, **kw)
        self.vbar['command'] = self.yview
        Text.grid(self, row=0, column=0, sticky="news")

        # Copy geometry methods of self.frame without overriding Text
        # methods -- hack!
        text_meths = vars(Text).keys()
        methods = vars(Pack).keys() | vars(Grid).keys() | vars(Place).keys()
        methods = methods.difference(text_meths)

        for m in methods:
            if m[0] != '_' and m != 'config' and m != 'configure' and m not in [
                    "grid", "pack"
            ]:
                setattr(self, m, getattr(self.frame, m))

    def __str__(self):
        return str(self.frame)

    def pack(self, *args, **kwargs):
        self.frame.pack(*args, **kwargs)
        #self.frame.pack_propagate(False)

    def grid(self, *args, **kwargs):
        self.frame.grid(*args, **kwargs)
Exemple #17
0
 def _build_listbox(self, values):
     listbox_frame = Frame()
     self._listbox = Listbox(listbox_frame, background="white",
                             selectmode=SINGLE, activestyle="none",
                             exportselection=False)
     self._listbox.grid(row=0, column=0, sticky=N+E+W+S)
     self._listbox.bind("<ButtonRelease-1>",
                        self._update_entry_from_listbox)
     self._listbox.bind("<Return>", self._update_entry_from_listbox)
     self._listbox.bind("<Escape>", lambda event: self.unpost_listbox())
     self._listbox.bind('<Control-n>', self._next)
     self._listbox.bind('<Control-p>', self._previous)
     if self._use_vscrollbar:
         vbar = Scrollbar(listbox_frame, orient=VERTICAL,
                          command=self._listbox.yview)
         vbar.grid(row=0, column=1, sticky=N+S)
         self._listbox.configure(
             yscrollcommand=lambda f, l: autoscroll(vbar, f, l))
     elif self._use_hscrollbar:
         hbar = Scrollbar(listbox_frame, orient=HORIZONTAL,
                          command=self._listbox.xview)
         hbar.grid(row=1, column=0, sticky=E+W)
         self._listbox.configure(
             xscrollcommand=lambda f, l: autoscroll(hbar, f, l))
     listbox_frame.grid_columnconfigure(0, weight=1)
     listbox_frame.grid_rowconfigure(0, weight=1)
     x = -self.cget("borderwidth") - self.cget("highlightthickness")
     y = self.winfo_height()-self.cget("borderwidth") - \
         self.cget("highlightthickness")
     elif self._listbox_width:
         width = self._listbox_width
Exemple #18
0
 def create_module_panel(self):
     frm_mod = Frame(self.ntbk)
     frm_mod.grid_columnconfigure(0, weight=1)
     frm_mod.grid_rowconfigure(0, weight=1)
     self.module_txt = Text(frm_mod)
     self.module_txt.grid(row=0, column=0, sticky=(N, S, W, E))
     self.module_txt.config(state=DISABLED)
     self.ntbk.add(frm_mod, text=ugettext('Modules'))
Exemple #19
0
 def create_module_panel(self):
     frm_mod = Frame(self.ntbk)
     frm_mod.grid_columnconfigure(0, weight=1)
     frm_mod.grid_rowconfigure(0, weight=1)
     self.module_txt = Text(frm_mod)
     self.module_txt.grid(row=0, column=0, sticky=(N, S, W, E))
     self.module_txt.config(state=DISABLED)
     self.ntbk.add(frm_mod, text=ugettext('Modules'))
Exemple #20
0
def upload_film_data():
    current_folder = os.getcwd()
    os.chdir(os.path.dirname(sys.argv[0]))
    img = Image.open(Globals.map_dose_film_dataset.get())
    if(not (img.width == 1016 or img.width == 576)):
        messagebox.showerror("Error", "Dpi in image has to be 127 or 72")
        return

    Globals.map_dose_isocenter_map_x_coord_scaled = []
    Globals.map_dose_isocenter_map_x_coord_unscaled = []
    Globals.map_dose_isocenter_map_y_coord_scaled = []
    Globals.map_dose_isocenter_map_y_coord_unscaled = []

    mark_isocenter_window = tk.Toplevel(Globals.tab3)
    mark_isocenter_window.grab_set()
    frame = Frame(mark_isocenter_window, bd=2, relief=SUNKEN)
    frame.grid_rowconfigure(0, weight=1)
    frame.grid_columnconfigure(0, weight=1)
    canvas = Canvas(frame, bd=0)
    canvas.grid(row=0, column=0, sticky=N+S+E+W)

    
    scale_horizontal = img.width/408
    scale_vertical = img.height/508
    img = img.resize((408,508))
    img = ImageTk.PhotoImage(image=img)
    os.chdir(current_folder)
    canvas.image = img

    w = 10 + img.width()
    h = 10 + img.height()
    mark_isocenter_window.geometry("%dx%d+0+0" % (w, h))
    canvas.create_image(0,0,image=img,anchor="nw")
    canvas.config(scrollregion=canvas.bbox(ALL), cursor='sb_up_arrow')
    #x_coor = []
    #y_coor = []
    
    def findCoords(event):
        Globals.map_dose_isocenter_map_x_coord_scaled.append(event.x*scale_vertical)
        Globals.map_dose_isocenter_map_y_coord_scaled.append(event.y*scale_horizontal)
        Globals.map_dose_isocenter_map_x_coord_unscaled.append(event.x)
        Globals.map_dose_isocenter_map_y_coord_unscaled.append(event.y)
        canvas.create_oval(event.x-2, event.y-2, event.x+2, event.y+2, fill='red')
        if (len(Globals.map_dose_isocenter_map_x_coord_scaled)==1):
            canvas.config(cursor='sb_down_arrow')
        elif(len(Globals.map_dose_isocenter_map_x_coord_scaled)==2):
            canvas.config(cursor='sb_right_arrow')
        elif(len(Globals.map_dose_isocenter_map_x_coord_scaled)==3):
            canvas.config(cursor='sb_left_arrow')
        else:
            #mark_isocenter_window.destroy()
            draw_image_with_marks(img, scale_horizontal, scale_vertical, mark_isocenter_window, frame)
            
    
    
    canvas.bind("<Button 1>",findCoords)
    frame.pack(fill='both', expand=1)
Exemple #21
0
class MainController(Tk):
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)

        # The main container that contains the current frame
        self.container = Frame(self)
        self.container.pack(side=TOP, fill=BOTH, expand=True)
        self.container.grid_rowconfigure(0, weight=1)
        self.container.grid_columnconfigure(0, weight=1)

        # for mapping the spelling of the listed items with class names
        self.pages = {
            'MainPage': MainPage,
            'Caesar': Caesar,
            'Vigenere': Vigenere,
            'One-time pad': OTP,
            'MD5 Hash': MD5,
            'Base64 encode': Base64,
            'ASCII chart': ASCIIChart,
            'URL encode': URL,
            'UTF-8 encode': UTF8,
            'Unsigned Binary': Arithmetic,
            'Sign and Magnitude': Arithmetic,
            "One's Complement": Arithmetic,
            "Two's Complement": Arithmetic,
            'Hexadecimal': Arithmetic,
            'Modulus Calculator': Modulus,
            'All Numbers': AllNumbers,
            'All Numbers (alternate)': AllNumbersAlt,
            'Binary Representation': BinRep,
            'Data Storage Units': DUnits,
            'String to Binary': StrToBin,
            'Prime Number Checker': Prime,
            'RSA': rsa,
            'RSA Key Generator': RSAKeys,
            'Hexdump': Hdump
        }

        self.current_frame = Frame()
        self.show_frame("MainPage")

    def show_frame(self, page_name):
        """Change current page
        Show a frame given the page name and communicate to the frames
        with an optional option parameter
        """
        self.current_frame.grid_forget()  # clear frame's widgets
        self.current_frame = self.pages[page_name](parent=self.container,
                                                   controller=self)
        self.current_frame.grid(row=0, column=0, sticky=N + E + S + W)

        if self.pages[
                page_name].__name__ == 'Arithmetic':  # set an option when the frame is loaded
            self.current_frame.set_option(page_name)
        return
    def _build_listbox(self, values):
        listbox_frame = Frame()

        self._listbox = Listbox(listbox_frame,
                                background="white",
                                selectmode=tk.SINGLE,
                                activestyle="none",
                                exportselection=False)
        self._listbox.grid(row=0, column=0, sticky=tk.N + tk.E + tk.W + tk.S)

        self._listbox.bind("<ButtonRelease-1>",
                           self._update_entry_from_listbox)
        self._listbox.bind("<Return>", self._update_entry_from_listbox)
        self._listbox.bind("<Escape>", lambda event: self.unpost_listbox())

        self._listbox.bind('<Control-n>', self._next)
        self._listbox.bind('<Control-p>', self._previous)

        if self._use_vscrollbar:
            vbar = Scrollbar(listbox_frame,
                             orient=tk.VERTICAL,
                             command=self._listbox.yview)
            vbar.grid(row=0, column=1, sticky=tk.N + tk.S)

            self._listbox.configure(
                yscrollcommand=lambda f, l: autoscroll(vbar, f, l))

        if self._use_hscrollbar:
            hbar = Scrollbar(listbox_frame,
                             orient=tk.HORIZONTAL,
                             command=self._listbox.xview)
            hbar.grid(row=1, column=0, sticky=tk.E + tk.W)

            self._listbox.configure(
                xscrollcommand=lambda f, l: autoscroll(hbar, f, l))

        listbox_frame.grid_columnconfigure(0, weight=1)
        listbox_frame.grid_rowconfigure(0, weight=1)

        x = -self.cget("borderwidth") - self.cget("highlightthickness")
        y = self.winfo_height() - self.cget("borderwidth") - self.cget(
            "highlightthickness")

        if self._listbox_width:
            width = self._listbox_width
        else:
            width = self.winfo_width()

        listbox_frame.place(in_=self, x=x, y=y, width=width)

        height = min(self._listbox_height, len(values))
        self._listbox.configure(height=height)

        for item in values:
            self._listbox.insert(END, item)
    def __init_frames(self):

        container = Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        for frame in (AboutFrame, CourseFrame, EnrollmentFrame, StudentFrame):
            current_frame = frame(container)
            self.frames[frame.__name__] = current_frame
            current_frame.grid(row=0, column=0, sticky="nsew")
Exemple #24
0
    def create_bottom_frame(self):
        bottom_frame = Frame(self.master)
        self.create_left_frame(bottom_frame)
        self.create_right_frame(bottom_frame)

        bottom_frame.grid_columnconfigure(0, weight=1, uniform="group1")
        bottom_frame.grid_columnconfigure(1, weight=1, uniform="group1")
        bottom_frame.grid_rowconfigure(0, weight=1)

        bottom_frame.pack()
        return bottom_frame
    def init_gui(self, cim):
        """Make a new tkinter window"""
        root = Tk()
        root.grid_rowconfigure(0, weight=1)
        root.columnconfigure(0, weight=1)
        root.title(cim)
        root.resizable(False, True)
        frame_main = Frame(root)
        frame_main.grid(sticky='news')

        # Create a frame for the canvas with non-zero row&column weights
        frame_canvas = Frame(frame_main)
        frame_canvas.grid(row=0, column=0)
        frame_canvas.grid_rowconfigure(0, weight=1)
        frame_canvas.grid_columnconfigure(0, weight=1)
        # Set grid_propagate to False to allow 5-by-5 buttons resizing later
        frame_canvas.grid_propagate(False)

        # Add a canvas in that frame
        canvas = Canvas(frame_canvas)
        canvas.grid(row=0, column=0)
        canvas.pack(fill="both", expand=True)

        # Link a scrollbar to the canvas
        vsb = Scrollbar(frame_canvas, orient="vertical", command=canvas.yview)
        vsb.grid(row=0, column=1, sticky='ns')
        canvas.configure(yscrollcommand=vsb.set)

        # Create a frame to contain the scrollable content
        frame_progress = Frame(canvas)
        canvas.create_window((0, 0), window=frame_progress, anchor='nw')
        self.canvas = canvas
        self.frame_main = frame_main

        for process in self.process_list:
            self.init_new_progressbar(frame_progress,
                                      p_length=300,
                                      p_process=process)
        frame_progress.update_idletasks()
        p = self.process_list[0]
        frame_width = p['task_label'].winfo_width(
        ) + p['progressbar'].winfo_width() + p['status_label'].winfo_width()
        rows = 20 if len(self.process_list) > 20 else len(self.process_list)
        frame_height = (p['progressbar'].winfo_height() * rows)
        frame_canvas.config(width=frame_width + vsb.winfo_width(),
                            height=frame_height)
        canvas.config(width=frame_width + vsb.winfo_width(),
                      height=frame_height)
        canvas.config(scrollregion=canvas.bbox("all"))
        canvas.update()

        self.frame_main.bind("<Configure>", self.configure)

        return root
Exemple #26
0
def display_settings_ui(master):
    top = Toplevel(master)
    top.resizable(width=False, height=False)

    body = Frame(top, width=400, height=150)

    Label(body, text="Model:").grid(row=0, column=0, sticky="e")
    Label(body, text="Hostname:").grid(row=1, column=0, sticky="e")
    Label(body, text="URL Post:").grid(row=2, column=0, sticky="e")
    Label(body, text="Video capture:").grid(row=3, column=0, sticky="e")
    Label(body, text="Post by minute:").grid(row=4, column=0, sticky="e")

    model = Entry(body)
    model.grid(row=0, column=1, sticky="we", padx=2, pady=2)

    inputs = {
        "modelPath": StringVar(),
        "hostname": StringVar(),
        "urlPost": StringVar(),
        "videoCapture": StringVar(),
        "postByMinute": IntVar(),
    }

    row = 0
    inputs["modelPath"].set(config.SETTINGS.model_path)
    inputs["hostname"].set(config.SETTINGS.hostname)
    inputs["urlPost"].set(config.SETTINGS.url_post)
    inputs["videoCapture"].set(config.SETTINGS.video_capture)
    inputs["postByMinute"].set(config.SETTINGS.post_by_minute)

    for k, var in inputs.items():
        Entry(body, textvariable=var).grid(row=row, column=1, sticky="we", padx=2, pady=2)
        row += 1

    Button(body, text="...",
           command=partial(openfile, master, handle_file(inputs["modelPath"]))) \
        .grid(row=0, column=2, sticky="we", padx=2, pady=2)

    pack_btm_buttons = Frame(body)

    start = Button(pack_btm_buttons, text="Save",
                   command=partial(save_settings, top, **inputs))
    start.pack(side="left", fill=None, expand=False)

    pack_btm_buttons.grid(row=6, column=1, columnspan=2, sticky="e", padx=2, pady=2)

    body.grid(row=0, column=0, padx=5)
    body.grid_propagate(0)

    body.grid_rowconfigure(0, weight=1)

    body.grid_columnconfigure(1, weight=1)
    body.grid_columnconfigure(1, weight=1)
Exemple #27
0
    def create_frame_layout(self):
        """Create basic grid for this app."""
        # create the main containers
        top_cont = Frame(self.root,
                         bg=BG,
                         padx=6,
                         width=WIDTH,
                         height=HEIGHT * (1 / 5))
        btm_cont = Frame(self.root,
                         bg=BG,
                         padx=6,
                         pady=6,
                         width=WIDTH,
                         height=HEIGHT * (4 / 5))
        # layout the main containers
        top_cont.grid(row=0, sticky='ew')
        btm_cont.grid(row=1, sticky='nsew')
        top_cont.grid_rowconfigure(0, weight=1)
        top_cont.grid_columnconfigure(1, weight=1)

        # create the top frames
        logo_frame = Frame(top_cont,
                           width=WIDTH * (1 / 4),
                           height=HEIGHT * (1 / 5))
        logo_img = PhotoImage(file='img/bp_cuff.gif')
        logo = Label(logo_frame, bg=BG, image=logo_img)
        logo.image = logo_img
        logo.grid(row=0, column=0, ipadx=6, ipady=6, sticky='nsew')
        self.action_frame = Frame(top_cont,
                                  bg='magenta',
                                  width=WIDTH * (3 / 4),
                                  height=HEIGHT * (1 / 5))
        # layout the top frames
        logo_frame.grid(row=0, column=0, sticky='nsew')
        self.action_frame.grid(row=0, column=1, sticky='nsew')

        # create the bottom frames
        btm_cont.grid_rowconfigure(0, weight=1)
        btm_cont.grid_columnconfigure(0, weight=1)
        self.chart_frame = Frame(btm_cont,
                                 bg=BG,
                                 width=WIDTH * (2 / 3),
                                 height=HEIGHT * (4 / 5))
        self.stats_frame = LabelFrame(btm_cont,
                                      bg=BG,
                                      text=' Stats ',
                                      padx=6,
                                      width=WIDTH * (1 / 3),
                                      height=HEIGHT * (4 / 5))
        # layout the bottom frames
        self.chart_frame.pack(expand=True, fill='both', side='left')
        self.stats_frame.pack(fill='both', side='right')
Exemple #28
0
def get_fire_frame(master, markdown_var: StringVar, html_var: StringVar):
    parent = Frame(master)
    edit_frame = get_md_edit_frame(parent, markdown_var)
    preview_frame = get_md_preview_frame(parent, html_var)

    edit_frame.grid(row=0, column=0, sticky="nsew")
    preview_frame.grid(row=0, column=1, sticky="nsew")

    parent.grid_columnconfigure(0, weight=1, uniform="group1")
    parent.grid_columnconfigure(1, weight=1, uniform="group1")

    parent.grid_rowconfigure(0, weight=1)

    return parent
    def __init__(self, updater):
        Tk.__init__(self)

        self.left_img = PhotoImage(file='images/left_white.png')
        self.right_img = PhotoImage(file='images/right_white.png')

        self.active_frame = -1
        self.config(bg="#333")

        Button(self,
               bg="#333",
               fg="#333",
               activebackground='#333',
               image=self.left_img,
               highlightthickness=0,
               bd=0,
               padx=50,
               command=lambda: self.next_frame(False)).pack(side="left",
                                                            fill="y")

        Button(self,
               bg="#333",
               fg="#333",
               activebackground='#333',
               image=self.right_img,
               highlightthickness=0,
               bd=0,
               padx=50,
               command=lambda: self.next_frame(True)).pack(side="right",
                                                           fill="y")

        container = Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = []

        for F in [Frame1, TimersFrame, WeatherFrame,
                  IsItFridayFrame]:  #, SensorsFrame]: #, HouseMapFrame]:
            page_name = F.__name__
            frame = F(parent=container, updater=updater)
            self.frames.append(frame)

            # put all of the pages in the same location;
            # the one on the top of the stacking order
            # will be the one that is visible.
            frame.grid(row=0, column=0, sticky="nsew")

        self.next_frame(True)  #show_frame("Frame1")
Exemple #30
0
    def start(self):
        """Methods sets the common frames across all of the views, as well as
        a common list of action buttons (e.g. start, exit) at the bottom of all the views.
        """
        self._root.grid_rowconfigure(0, weight=1)
        self._root.grid_columnconfigure(0, weight=1)

        center_frame = Frame(
            self._root,
            width=self._root_width,
            heigh=self._root_height - self._bottom_height,
        )

        bottom_frame = Frame(
            self._root,
            bg="black",
            width=self._root_width,
            height=self._bottom_height,
        )

        center_frame.grid(row=0, column=0, sticky="nsew")

        bottom_frame.grid(row=1, column=0, sticky="nsew")

        bottom_frame.grid_rowconfigure(1)
        bottom_frame.grid_columnconfigure([0, 1, 2, 3, 4, 5, 6, 7],
                                          minsize=(self._root_width / 8))

        bottom_frame_headlines = ["Intro", "Options", "Start", "Exit"]
        commands = [
            lambda: self._show_intro_view(center_frame),
            lambda: self._show_options_view(center_frame),
            lambda: self._show_game_view(center_frame), self._quit
        ]

        for j in range(0, len(bottom_frame_headlines)):
            button = Button(bottom_frame,
                            text=bottom_frame_headlines[j],
                            compound="center",
                            width=12,
                            height=1,
                            background="red",
                            activebackground="red",
                            font=self.fonts.small_text_font,
                            command=commands[j])

            button.grid(row=0, column=j, padx=12, pady=12)

        self._show_opening_view(center_frame)
    def __init__(self):
        Tk.__init__(self)
        Tk.wm_title(self, 'Five in a Row')

        container = Frame(self)
        container.pack(side='top', fill='both', expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}
        frame = GameUI(container, self)
        self.frames[GameUI] = frame
        frame.grid(row=0, column=0, sticky='nsew')

        self.show_frame(GameUI)
Exemple #32
0
def draw_ROI(img, scale_horizontal, scale_vertical):
    draw_ROI_window = tk.Toplevel(Globals.tab3)
    draw_ROI_window.grab_set()
    local_frame= Frame(draw_ROI_window, bd = 2, relief=SUNKEN)
    local_frame.grid_rowconfigure(0,weight=1)
    local_frame.grid_columnconfigure(0, weight=1)

    local_canvas = Canvas(local_frame, bd=0)
    local_canvas.grid(row=0,column=0, sticky=N+S+E+W)

    w = 10 + img.width()
    h = 10 + img.height()
    draw_ROI_window.geometry("%dx%d+0+0" % (w, h))

    local_canvas.create_image(0,0,image=img,anchor="nw")
    local_canvas.config(scrollregion=local_canvas.bbox(ALL), cursor='arrow')
    local_canvas.image= img
    
    rectangle = local_canvas.create_rectangle(0,0,0,0,outline='green')

    def buttonPushed(event):
        Globals.map_dose_ROI_x_start.set(event.x)
        Globals.map_dose_ROI_y_start.set(event.y)
        
    def buttonMoving(event):
        local_canvas.coords(rectangle, Globals.map_dose_ROI_x_start.get(), Globals.map_dose_ROI_y_start.get(), \
            event.x, event.y)

    def buttonReleased(event):
        Globals.map_dose_ROI_x_end.set(event.x)
        Globals.map_dose_ROI_y_end.set(event.y)
        local_canvas.coords(rectangle, Globals.map_dose_ROI_x_start.get(), Globals.map_dose_ROI_y_start.get(),\
            Globals.map_dose_ROI_x_end.get(), Globals.map_dose_ROI_y_end.get())
        local_canvas.itemconfig(rectangle, outline='Blue')
        answer = messagebox.askquestion("Question","Happy with placement?", parent=draw_ROI_window)
        if(answer=='yes'):
            Globals.map_dose_ROI_x_start.set(Globals.map_dose_ROI_x_start.get()*scale_horizontal)
            Globals.map_dose_ROI_y_start.set(Globals.map_dose_ROI_y_start.get()*scale_vertical)
            Globals.map_dose_ROI_x_end.set(Globals.map_dose_ROI_x_end.get()*scale_horizontal)
            Globals.map_dose_ROI_y_end.set(Globals.map_dose_ROI_y_end.get()*scale_vertical)
            prepare_Image()
            draw_ROI_window.destroy()
    
    local_canvas.bind("<B1-Motion>", buttonMoving)
    local_canvas.bind("<Button-1>", buttonPushed)
    local_canvas.bind("<ButtonRelease-1>", buttonReleased)

    local_frame.pack(fill='both', expand=1)
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)

        # call closing protocol to create dialog box to ask
        # if user if they want to quit or not.
        self.protocol("WM_DELETE_WINDOW", self.on_closing)

        Tk.wm_title(self, "Survey (中文版)")

        # get position of window with respect to screen
        windowWidth, windowHeight = 555, 400
        positionRight = int(Tk.winfo_screenwidth(self) / 2 - windowWidth / 2)
        positionDown = int(Tk.winfo_screenheight(self) / 2 - windowHeight / 2)
        Tk.geometry(self,
                    newGeometry="{}x{}+{}+{}".format(windowWidth, windowHeight,
                                                     positionRight,
                                                     positionDown))
        Tk.maxsize(self, windowWidth, windowHeight)

        # Create container Frame to hold all other classes,
        # which are the different parts of the survey.
        container = Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        # Create menu bar
        menubar = Menu(container)
        filemenu = Menu(menubar, tearoff=0)
        filemenu.add_command(label="Quit", command=quit)
        menubar.add_cascade(label="File", menu=filemenu)

        Tk.config(self, menu=menubar)

        # create empty dictionary for the different frames (the different classes)
        self.frames = {}

        for fr in (StartPage, LifeStyleSurveyPages,
                   SignificantConsumptionTrendsSurveyPages,
                   FutureConsumptionTrendsSurveyPages, GenderQuestion,
                   MarriageQuestion, AgeQuestion, WorkQuestion,
                   EdBackgroundQuestion, SalaryQuestion, RelationQuestion,
                   TimeQuestion, TransitQuestion, ExpensesQuestion):
            frame = fr(container, self)
            self.frames[fr] = frame
            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame(StartPage)
Exemple #34
0
    def __init__(self, *args, **kw):
        Tk.__init__(self, *args, **kw)
        container = Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.ontop = None
        self.frames = {}
        for F in (Snak, Multiplayer, Stats, Credits, Startup):
            page_name = F.__name__
            frame = F(parent=container, controller=self)
            self.frames[page_name] = frame
            frame.grid(row=0, column=0, sticky="nsew")

        self.show_frame("Startup")
    def __init__(self, *args, **kwargs):
        tk.Tk.__init__(self, *args, **kwargs)

        # Container where the different Frames stack
        container = Frame(self)
        container.pack(side='top', fill='both', expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}
        for F in (Main, ReadFromFile, AddManually):
            page_name = F.__name__
            frame = F(container, self)
            self.frames[page_name] = frame

            frame.grid(row=0, column=0, sticky='nsew')

        self.show_frame('Main')
Exemple #36
0
class Momentary:
    def __init__(self, master, valves):
        self.valves = valves

        self.master = master
        self.frame1 = Frame(master)
        self.frame2 = Frame(master)

        self.master.configure(bg='sky blue')
        self.frame1.configure(bg='sky blue')
        self.frame2.configure(bg='sky blue')

        index = 0
        while index < 6:
            self.frame1.grid_columnconfigure(index, minsize=6)
            self.frame2.grid_columnconfigure(index, minsize=6)

            self.frame1.grid_rowconfigure(index, minsize=140)
            self.frame2.grid_rowconfigure(index, minsize=140)
            index += 1

        self.end_all_image = PhotoImage(file="img/stop.png").subsample(x=6, y=6)
        self.end_all_button = Button(self.master, image=self.end_all_image, command=lambda: self.end_all() )
        self.end_all_button.config(bg='brown3', activebackground='brown4', border=5, width=850)

        self.label = [Label(self.frame1, textvariable=self.valves[0].get_name()),
                      Label(self.frame1, textvariable=self.valves[1].get_name()),
                      Label(self.frame1, textvariable=self.valves[2].get_name()),
                      Label(self.frame1, textvariable=self.valves[3].get_name()),
                      Label(self.frame2, textvariable=self.valves[4].get_name()),
                      Label(self.frame2, textvariable=self.valves[5].get_name()),
                      Label(self.frame2, textvariable=self.valves[6].get_name()),
                      Label(self.frame2, textvariable=self.valves[7].get_name())]

        row = 0
        for each in self.label:
            each.config(width=7, height=2)
            each.config(bg='sky blue', fg='RoyalBlue4', font=('Lucida Console', 30), padx=18)
            each.grid(row=row % 4, column=0)
            row += 1

        self.lightsA = [LED(self.frame1, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame1, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame1, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame1, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame2, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame2, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame2, 30, 'green1', 'green', 'dark green', 'Dark Green', False),
                        LED(self.frame2, 30, 'green1', 'green', 'dark green', 'Dark Green', False)
                        ]

        self.lightsB = [LED(self.frame1, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame1, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame1, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame1, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame2, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame2, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame2, 30, 'red', 'dark red', 'red4', 'DarkRed', False),
                        LED(self.frame2, 30, 'red', 'dark red', 'red4', 'DarkRed', False)
                        ]

        self.v = [IntVar(),
                  IntVar(),
                  IntVar(),
                  IntVar(),
                  IntVar(),
                  IntVar(),
                  IntVar(),
                  IntVar()]

        for each in self.v:
            each.set(3)

        self.a = [Radiobutton(self.frame1, text='A', command=lambda: self.activate_a(0), value=1),
                  Radiobutton(self.frame1, text='A', command=lambda: self.activate_a(1), value=1),
                  Radiobutton(self.frame1, text='A', command=lambda: self.activate_a(2), value=1),
                  Radiobutton(self.frame1, text='A', command=lambda: self.activate_a(3), value=1),
                  Radiobutton(self.frame2, text='A', command=lambda: self.activate_a(4), value=1),
                  Radiobutton(self.frame2, text='A', command=lambda: self.activate_a(5), value=1),
                  Radiobutton(self.frame2, text='A', command=lambda: self.activate_a(6), value=1),
                  Radiobutton(self.frame2, text='A', command=lambda: self.activate_a(7), value=1)]

        index = 0
        for each in self.a:
            each.grid(row=index % 4, column=2)
            each.config(width=4, height=2,  indicatoron=0, variable=self.v[index], font=('Lucida Console', 30))
            each.config(bg='SkyBlue4', activebackground='midnight blue', selectcolor='midnight blue', fg='white')
            each.config(activeforeground='white')
            index += 1

        self.b = [Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(0), value=0),
                  Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(1), value=0),
                  Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(2), value=0),
                  Radiobutton(self.frame1, text='B', command=lambda: self.activate_b(3), value=0),
                  Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(4), value=0),
                  Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(5), value=0),
                  Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(6), value=0),
                  Radiobutton(self.frame2, text='B', command=lambda: self.activate_b(7), value=0)]

        index = 0
        for each in self.b:
            each.grid(row=index % 4, column=3)
            each.config(width=4, height=2,  indicatoron=0, variable=self.v[index], font=('Lucida Console', 30))
            each.config(bg='SkyBlue4', activebackground='midnight blue', selectcolor='midnight blue', fg='white')
            each.config(activeforeground='white')
            index += 1

        self.end_image = PhotoImage(file="img/no.png").subsample(x=6, y=6)
        self.end_button = [Radiobutton(self.frame1, image=self.end_image, command=lambda: self.end(0)),
                           Radiobutton(self.frame1, image=self.end_image, command=lambda: self.end(1)),
                           Radiobutton(self.frame1, image=self.end_image, command=lambda: self.end(2)),
                           Radiobutton(self.frame1, image=self.end_image, command=lambda: self.end(3)),
                           Radiobutton(self.frame2, image=self.end_image, command=lambda: self.end(4)),
                           Radiobutton(self.frame2, image=self.end_image, command=lambda: self.end(5)),
                           Radiobutton(self.frame2, image=self.end_image, command=lambda: self.end(6)),
                           Radiobutton(self.frame2, image=self.end_image, command=lambda: self.end(7)),
                           ]

        index = 0
        for each in self.end_button:
            each.grid(row=index % 4, column=5)
            each.config(value=2, variable=self.v[index], indicatoron=0)
            each.config(bg='brown3', activebackground='brown4')
            index += 1
        

    def make_frame(self):
        self.frame1.grid(row=2, column=0, rowspan=5)
        self.frame2.grid(row=2, column=1, rowspan=5)
        self.end_all_button.grid(row=1, column=0, columnspan=2)

        row = 0
        for each in self.lightsA:
            each.grid(row=row % 4, column=1, padx=20, pady=20)
            row += 1

        row = 0
        for each in self.lightsB:
            each.grid(row=row % 4, column=4, padx=20, pady=20)
            row += 1


    def delete_frame(self):
        self.frame1.grid_remove()
        self.frame2.grid_remove()
        self.end_all_button.grid_remove()

        for each in self.lightsA:
            each.grid_remove()

        for each in self.lightsB:
            each.grid_remove()

    def activate_a(self, number):
        pin_number = 65 + number
        pin_opposite = 80 - number

        if self.v[number].get() == 1:
            self.lightsA[number].set_state(True)
            self.lightsB[number].set_state(False)
            
            wiringpi.digitalWrite(pin_number, 1)
            wiringpi.digitalWrite(pin_opposite, 0)

    def activate_b(self, number):
        pin_number = 80 - number
        pin_opposite = 65 + number

        if self.v[number].get() == 0:
            self.lightsA[number].set_state(False)
            self.lightsB[number].set_state(True)
            wiringpi.digitalWrite(pin_number, 1)
            wiringpi.digitalWrite(pin_opposite, 0)
            

    def end(self, number):
        pin_number = 65 + number
        pin_opposite = 80 - number

        wiringpi.digitalWrite(pin_number, 0)
        wiringpi.digitalWrite(pin_opposite, 0)

        self.v[number].set(3)
        self.lightsA[number].set_state(False)
        self.lightsB[number].set_state(False)

    def end_all(self):
        number = 0
        while number < 8:
            self.end(number)
            number += 1
Exemple #37
0
class Keypad(Frame):
    def __init__(self, master, gui, password):
        Frame.__init__(self, master, bg='sky blue', width=450, height=550)
        self.master.geometry('400x550')
        self.master = master
        self.master.configure(bg='sky blue')
        self.gui = gui
        self.password = password
        self.frame = Frame(master)
        self.frame.pack()
        self.frame.configure(bg='sky blue')

        index = 0
        while index < 5:
            self.frame.grid_rowconfigure(index, minsize=50)
            index += 1

        index = 0
        while index < 5:
            self.frame.grid_columnconfigure(index, minsize=50)
            index += 1

        self.box = Entry(self.frame)

        self.box.grid(row=0, columnspan=3)
        self.box.config(font=('Lucida Console', 78), width=6)

        self.list1 = [Button(self.frame, font=('Lucida Console', 30), text='1', command=lambda: self.bob_print(1)),
                 Button(self.frame, font=('Lucida Console', 30), text='2', command=lambda: self.bob_print(2)),
                 Button(self.frame, font=('Lucida Console', 30), text='3', command=lambda: self.bob_print(3))
                ]

        index = 0
        for each in self.list1:
            each.grid(row=1, column=index)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white', activeforeground='white')
            each.config(height=2, width=4)
            index += 1

        self.list2 = [Button(self.frame, font=('Lucida Console', 30), text='4', command=lambda: self.bob_print(4)),
                 Button(self.frame, font=('Lucida Console', 30), text='5', command=lambda: self.bob_print(5)),
                 Button(self.frame, font=('Lucida Console', 30), text='6', command=lambda: self.bob_print(6))
                ]

        index = 0
        for each in self.list2:
            each.grid(row=2, column=index)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white', activeforeground='white')
            each.config(height=2, width=4)
            index += 1

        self.list3 = [Button(self.frame, font=('Lucida Console', 30), text='7', command=lambda: self.bob_print(7)),
                 Button(self.frame, font=('Lucida Console', 30), text='8', command=lambda: self.bob_print(8)),
                 Button(self.frame, font=('Lucida Console', 30), text='9', command=lambda: self.bob_print(9))
                ]

        index = 0
        for each in self.list3:
            each.grid(row=3, column=index)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white', activeforeground='white')
            each.config(height=2, width=4)
            index += 1

        self.list4 = [Button(self.frame, font=('Lucida Console', 30), text='<', command=lambda: self.bob_print('<')),
                 Button(self.frame, font=('Lucida Console', 30), text='0', command=lambda: self.bob_print(0)),
                 Button(self.frame, font=('Lucida Console', 30), text='E', command=lambda: self.bob_print('E'))
                ]

        index = 0
        for each in self.list4:
            each.grid(row=4, column=index)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white', activeforeground='white')
            each.config(height=2, width=4)
            index += 1

    def bob_print(self, character):
        if not (character is '<' or character is 'E'):
            self.box.insert("end", character)
        elif character is '<':
            string = self.box.get()
            self.box.delete(0, 'end')
            self.box.insert('end', string[:-1])
        else:
            if self.box.get() == self.password:
                self.gui.access_granted()
                self.master.destroy()
            else:
                self.box.delete(0, 'end')
Exemple #38
0
class GUI(object):
    '''Stellt die Oberflaeche dar.
    
    Alle steuerden Taetigkeiten werden (sollten) vom
    Controller Objekt uebernommen werden.
    '''


    def __init__(self):
        '''
        Constructor
        '''
        self.root = Tk()
        
        self.root.title("DinnerLog")
        self.root.minsize(800, 600)
        self.root.grid_columnconfigure(0, weight=1)
        self.root.grid_rowconfigure(0, weight=1)
        self.root.grid_rowconfigure(1, weight=3)
        
        # Ein Frame für alles, das mit Zutaten zu tun hat
        self.fr_zutaten = Labelframe(self.root, borderwidth=2, relief=GROOVE, text="Zutaten")
        self.fr_zutaten.grid_columnconfigure(0, weight=1)
        self.fr_zutaten.grid_rowconfigure(0, weight=1)
        self.fr_zutaten.grid(row=0, column=0, sticky="NSWE")
        

        self.lb_zutaten = Listbox(self.fr_zutaten)
        sb_zutaten = Scrollbar(self.lb_zutaten, orient=VERTICAL)
        self.lb_zutaten.configure(yscrollcommand=sb_zutaten.set)
        sb_zutaten.config(command=self.lb_zutaten.yview)
        sb_zutaten.pack(side="right", fill="both")
        self.lb_zutaten.grid(row=0, column=0, sticky="NSEW")
        
        self._addNeueZutatFrame()    

        # Ein Frame in den alles, das mit Mahlzeiten zu tun hat, kommt
        self.fr_mahlzeit = Labelframe(self.root, borderwidth=2, relief=GROOVE, text="Mahlzeiten")
        self.fr_mahlzeit.grid_columnconfigure(0, weight=1)
        self.fr_mahlzeit.grid_rowconfigure(0, weight=1)
        self.fr_mahlzeit.grid(row=1, column=0, sticky="NSWE")
        
        self._addNeueMahlzeitFrame()
        

        self.lb_mahlzeiten = Listbox(self.fr_mahlzeit, selectmode=SINGLE)
        sb_mahlzeiten = Scrollbar(self.lb_mahlzeiten, orient=VERTICAL)
        sb_mahlzeiten.configure(command=self.lb_mahlzeiten.yview)
        self.lb_mahlzeiten.configure(yscrollcommand=sb_mahlzeiten.set)
        sb_mahlzeiten.pack(side="right", fill="both")
        self.lb_mahlzeiten.grid(row=0, column=0, sticky="NSEW")
        
        fr_neu_ok = Frame(self.fr_mahlzeit)
        fr_neu_ok.grid(row=1, column=0, columnspan=2, sticky="E")
    
        self.btn_neu = Button(fr_neu_ok, text="Neu")
        self.btn_neu.pack(side="left")
        
        self.btn_mahlzeit_als_zt = Button(fr_neu_ok, text="Als Zutat")
        self.btn_mahlzeit_als_zt.pack(anchor=E, side="right")
        
        self.btn_insert = Button(fr_neu_ok, text="Hinzufuegen")
        self.btn_insert.pack(anchor=E, side="right")
        
        self.btn_update = Button(fr_neu_ok, text="Update")
        self.btn_update.pack(anchor=E, side="right")
        
        self.btn_delete = Button(fr_neu_ok, text="Loeschen")
        self.btn_delete.pack(anchor=E, side="right")
        
        # Ein Frame der Statistiken darstellt
        self.fr_stats = Labelframe(self.root, borderwidth=2, relief=GROOVE, text="Statistik")
        self.fr_stats.grid(row=3, column=0, sticky="NSWE")

        #self.cv_stats = Canvas(self.fr_stats, height=80, width=600)
        #self.cv_stats.create_line(2,5,598,5, fill="#bbb")
        
    def _addNeueMahlzeitFrame(self):
        self.fr_neue_mz = Frame(self.fr_mahlzeit)
        self.fr_neue_mz.grid_rowconfigure(2, weight=1)
        self.fr_neue_mz.grid(row=0, column=1, sticky="WSNE")
        
        lbl_name = Label(self.fr_neue_mz, text="Name:")
        lbl_name.grid(row=0, column=0, sticky="NW")
        
        self.en_name = Entry(self.fr_neue_mz)
        self.en_name.grid(row=0, column=1, columnspan=2, sticky="WNE")
        
        lbl_zutat = Label(self.fr_neue_mz, text="Zutaten:")
        lbl_zutat.grid(row=1, column=0, sticky="NW")
        

        self.lb_zutat = Listbox(self.fr_neue_mz)
        sb_zutat = Scrollbar(self.lb_zutat, orient=VERTICAL)
        self.lb_zutat.configure(yscrollcommand=sb_zutat.set)
        sb_zutat.configure(command=self.lb_zutat.yview)
        sb_zutat.pack(side="right", fill="both")
        self.lb_zutat.grid(row=2, column=0, columnspan=3, sticky="NWSE")
        
        self.var_zutat = StringVar(self.fr_neue_mz)
        
        self.opt_zutat = OptionMenu(self.fr_neue_mz, self.var_zutat, "Auswahl")
        self.opt_zutat.grid(row=3, column=0)
        
        self.en_menge = Entry(self.fr_neue_mz)
        self.en_menge.grid(row=3, column=1)
        
        self.btn_mahlzeit_hinzu = Button(self.fr_neue_mz, text="Hinzu")
        self.btn_mahlzeit_hinzu.grid(row=3, column=2, sticky="E")
        
    def _addNeueZutatFrame(self):
        fr_neue_zt = Frame(self.fr_zutaten)
        fr_neue_zt.grid(row=0, column=2,sticky="NWSE")
        
        lbl_name = Label(fr_neue_zt, text="Name:")
        lbl_name.grid(row=0, column=0, sticky="W")
        
        self.en_name_zt = Entry(fr_neue_zt)
        self.en_name_zt.grid(row=0, column=1, columnspan=2, sticky="WE")
        
        lbl_fett = Label(fr_neue_zt, text="Fett:")
        lbl_fett.grid(row=1, column=0, sticky="W")        
        
        self.en_fett = Entry(fr_neue_zt)
        self.en_fett.grid(row=1, column=1, columnspan=2)
        
        lbl_eiweiss = Label(fr_neue_zt, text="Eiweiss:")
        lbl_eiweiss.grid(row=2, column=0, sticky="W")        
        
        self.en_eiweiss = Entry(fr_neue_zt)
        self.en_eiweiss.grid(row=2, column=1, columnspan=2)
        
        lbl_kh = Label(fr_neue_zt, text="Kohlenhy.:")
        lbl_kh.grid(row=3, column=0, sticky="W")        
        
        self.en_kh = Entry(fr_neue_zt)
        self.en_kh.grid(row=3, column=1, columnspan=2)
        
        self.btn_zutat_insert = Button(fr_neue_zt, text="Hinzu")
        self.btn_zutat_insert.grid(row=4, column=1, sticky="E")
        
        self.btn_zutat_update = Button(fr_neue_zt, text="Update")
        self.btn_zutat_update.grid(row=5, column=1, sticky="E")
        
        self.btn_zutat_delete = Button(fr_neue_zt, text="Loeschen")
        self.btn_zutat_delete.grid(row=6, column=1, sticky="E")
Exemple #39
0
class Edit(Frame):
    def __init__(self, master, valves):
        Frame.__init__(self, master, bg='sky blue', width=1366, height=768)
        self.master = master

        self.canvas = Canvas(self, height=630, width=1320, bg='sky blue')
        self.frame = Frame(self.canvas, bg='sky blue')
        self.scrollbar = Scrollbar(self, orient='vertical', command=self.canvas.yview)
        self.scrollbar.configure(activebackground='DarkRed', background='red', width=40)
        self.canvas.configure(yscrollcommand=self.scrollbar.set, scrollregion=[0, 0, 1366, 800])

        self.scrollbar.pack(side='right', fill='y')
        self.canvas.pack(side='left')
        self.canvas.create_window((0, 0), window=self.frame, anchor='nw')
        
        self.valves = valves
        self.frame.config(bg='sky blue')

        index = 0
        while index < 10:
            self.frame.grid_rowconfigure(index, minsize=80)
            self.frame.grid_columnconfigure(index, minsize=30)
            index += 1

        self.frame.grid_columnconfigure(3, minsize=130)
        self.frame.grid_columnconfigure(6, minsize=130)

        interval = Label(self.frame, text='RUN', width=6, font=('Lucida Console', 30))
        interval.grid(row=0, column=2)
        interval.config(bg='sky blue', fg='RoyalBlue4')

        delay = Label(self.frame, text='DELAY', width=6, font=('Lucida Console', 30))
        delay.grid(row=0, column=5)
        delay.config(bg='sky blue', fg='RoyalBlue4')

        self.seconds = [IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar(),
                        IntVar()]

        for each in self.seconds:
            each.set(0)

        self.set_seconds()

        self.valve_label = [Label(self.frame, textvariable=self.valves[0].get_name()),
                            Label(self.frame, textvariable=self.valves[1].get_name()),
                            Label(self.frame, textvariable=self.valves[2].get_name()),
                            Label(self.frame, textvariable=self.valves[3].get_name()),
                            Label(self.frame, textvariable=self.valves[4].get_name()),
                            Label(self.frame, textvariable=self.valves[5].get_name()),
                            Label(self.frame, textvariable=self.valves[6].get_name()),
                            Label(self.frame, textvariable=self.valves[7].get_name())
                            ]
       
        row = 1
        for each in self.valve_label:
            each.grid(row=row, column=0)
            each.config(width=8, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
            row += 1

        self.minus_image = PhotoImage(file="img/minus.png").subsample(x=5, y=5)
        self.minusInterval = [Button(self.frame, image=self.minus_image, command=lambda: self.subtract(0)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(1)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(2)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(3)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(4)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(5)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(6)),
                              Button(self.frame, image=self.minus_image, command=lambda: self.subtract(7)),
                              ]

        row = 1
        for each in self.minusInterval:
            each.grid(row=row, column=1)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white')
            row += 1

        self.labelInterval = [Label(self.frame, textvariable=self.seconds[0]),
                              Label(self.frame, textvariable=self.seconds[1]),
                              Label(self.frame, textvariable=self.seconds[2]),
                              Label(self.frame, textvariable=self.seconds[3]),
                              Label(self.frame, textvariable=self.seconds[4]),
                              Label(self.frame, textvariable=self.seconds[5]),
                              Label(self.frame, textvariable=self.seconds[6]),
                              Label(self.frame, textvariable=self.seconds[7])]
        row = 1
        for each in self.labelInterval:
            each.grid(row=row, column=2)
            each.config(width=4, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
            row += 1

        self.plus_image = PhotoImage(file="img/plus.png").subsample(x=5, y=5)
        self.plusInterval = [Button(self.frame, image=self.plus_image, command=lambda: self.add(0)),
                             Button(self.frame, image=self.plus_image, command=lambda: self.add(1)),
                             Button(self.frame, image=self.plus_image, command=lambda: self.add(2)),
                             Button(self.frame, image=self.plus_image, command=lambda: self.add(3)),
                             Button(self.frame, image=self.plus_image, command=lambda: self.add(4)),
                             Button(self.frame, image=self.plus_image, command=lambda: self.add(5)),
                             Button(self.frame, image=self.plus_image, command=lambda: self.add(6)),
                             Button(self.frame, image=self.plus_image, command=lambda: self.add(7)),
                             ]

        row = 1
        for each in self.plusInterval:
            each.grid(row=row, column=3)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white')
            row += 1

        self.minusDelay = [Button(self.frame, image=self.minus_image, command=lambda: self.subtract(8)),
                           Button(self.frame, image=self.minus_image, command=lambda: self.subtract(9)),
                           Button(self.frame, image=self.minus_image, command=lambda: self.subtract(10)),
                           Button(self.frame, image=self.minus_image, command=lambda: self.subtract(11)),
                           Button(self.frame, image=self.minus_image, command=lambda: self.subtract(12)),
                           Button(self.frame, image=self.minus_image, command=lambda: self.subtract(13)),
                           Button(self.frame, image=self.minus_image, command=lambda: self.subtract(14)),
                           Button(self.frame, image=self.minus_image, command=lambda: self.subtract(15)),
                           ]
        row = 1
        for each in self.minusDelay:
            each.grid(row=row, column=4)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white')
            each.config()
            row += 1

        self.labelDelay = [Label(self.frame, textvariable=self.seconds[8]),
                           Label(self.frame, textvariable=self.seconds[9]),
                           Label(self.frame, textvariable=self.seconds[10]),
                           Label(self.frame, textvariable=self.seconds[11]),
                           Label(self.frame, textvariable=self.seconds[12]),
                           Label(self.frame, textvariable=self.seconds[13]),
                           Label(self.frame, textvariable=self.seconds[14]),
                           Label(self.frame, textvariable=self.seconds[15])]
        row = 1
        for each in self.labelDelay:
            each.grid(row=row, column=5)
            each.config(width=4, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
            row += 1

        self.plusDelay = [Button(self.frame, image=self.plus_image, command=lambda: self.add(8)),
                          Button(self.frame, image=self.plus_image, command=lambda: self.add(9)),
                          Button(self.frame, image=self.plus_image, command=lambda: self.add(10)),
                          Button(self.frame, image=self.plus_image, command=lambda: self.add(11)),
                          Button(self.frame, image=self.plus_image, command=lambda: self.add(12)),
                          Button(self.frame, image=self.plus_image, command=lambda: self.add(13)),
                          Button(self.frame, image=self.plus_image, command=lambda: self.add(14)),
                          Button(self.frame, image=self.plus_image, command=lambda: self.add(15)),
                          ]
        row = 1
        for each in self.plusDelay:
            each.grid(row=row, column=6)
            each.config(bg='SkyBlue4', activebackground='midnight blue')
            each.config()
            row += 1

        self.motor_image = PhotoImage(file="img/motor.png").subsample(x=5, y=5)
        self.motor = [Button(self.frame, text='MOTOR', image=self.motor_image, command=lambda: self.motor_on(0)),
                      Button(self.frame, text='MOTOR', image=self.motor_image, command=lambda: self.motor_on(1)),
                      Button(self.frame, text='MOTOR', image=self.motor_image, command=lambda: self.motor_on(2)),
                      Button(self.frame, text='MOTOR', image=self.motor_image, command=lambda: self.motor_on(3)),
                      Button(self.frame, text='MOTOR', image=self.motor_image, command=lambda: self.motor_on(4)),
                      Button(self.frame, text='MOTOR', image=self.motor_image, command=lambda: self.motor_on(5)),
                      Button(self.frame, text='MOTOR', image=self.motor_image, command=lambda: self.motor_on(6)),
                      Button(self.frame, text='MOTOR', image=self.motor_image, command=lambda: self.motor_on(7))]

        row = 1
        for each in self.motor:
            each.grid(row=row, column=7)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white')
            each.config()
            row += 1

        self.adv_image = PhotoImage(file="img/options.png").subsample(x=5, y=5)
        self.adv = [Button(self.frame, image=self.adv_image, command=lambda: self.motor_on(0)),
                    Button(self.frame, image=self.adv_image, command=lambda: self.motor_on(1)),
                    Button(self.frame, image=self.adv_image, command=lambda: self.motor_on(2)),
                    Button(self.frame, image=self.adv_image, command=lambda: self.motor_on(3)),
                    Button(self.frame, image=self.adv_image, command=lambda: self.motor_on(4)),
                    Button(self.frame, image=self.adv_image, command=lambda: self.motor_on(5)),
                    Button(self.frame, image=self.adv_image, command=lambda: self.motor_on(6)),
                    Button(self.frame, image=self.adv_image, command=lambda: self.motor_on(7)),
                    ]

        row = 1
        for each in self.adv:
            each.grid(row=row, column=8)
            each.config(bg='SkyBlue4', activebackground='midnight blue', fg='white')
            row += 1
            
        self.set_seconds()
        self.lock()
            
    def lock(self):
        index = 0
        while index < 8:
            self.minusInterval[index].config(state='disabled')
            self.minusDelay[index].config(state='disabled')
            self.plusInterval[index].config(state='disabled')
            self.plusDelay[index].config(state='disabled')
            self.motor[index].config(state='disabled')
            self.adv[index].config(state='disabled')
            index += 1

    def set_seconds(self):
        index = 0
        while index < 8:
            if self.valves[index].get_setting() == 'DEFAULT':
                interval = self.valves[index].get_interval()
                # setting seconds for runtime
                self.seconds[index].set(interval[0])
                # setting seconds for delay
                self.seconds[index + 8].set(interval[1])
            else:
                self.minusInterval[index].config(state='disabled')
                self.minusDelay[index].config(state='disabled')
                self.plusInterval[index].config(state='disabled')
                self.plusDelay[index].config(state='disabled')
            index += 1

    def get_intervals(self):
        return self.seconds

    def motor_on(self, index):

        if self.minusDelay[index].cget('state') == 'normal':
            self.minusInterval[index].config(state='disabled')
            self.minusDelay[index].config(state='disabled')
            self.plusInterval[index].config(state='disabled')
            self.plusDelay[index].config(state='disabled')
            self.adv[index].config(state='disabled')
            self.seconds[index].set(0)
            self.seconds[index + 8].set(0)
        else:
            interval = self.valves[index].get_interval()
            self.minusInterval[index].config(state='normal')
            self.minusDelay[index].config(state='normal')
            self.plusInterval[index].config(state='normal')
            self.plusDelay[index].config(state='normal')
            self.adv[index].config(state='normal')
            self.seconds[index].set(interval[0])
            self.seconds[index + 8].set(interval[1])

    def add(self, number):
        if self.seconds[number].get() < 99:
            self.seconds[number].set(self.seconds[number].get() + 1)

    def subtract(self, number):
        if self.seconds[number].get() > 0:
            self.seconds[number].set(self.seconds[number].get() - 1)
Exemple #40
0
def tail(f):
    line = f.readline()
    while line:
        logfile.insert('end', line)
        logfile.see("end")
        line = f.readline()
    logfile.after(100, tail, f)


root = Tk()
""""
def callback():
	not(autoscroll)
"""
logframe = Frame(root, relief='ridge', bd=2)
logframe.grid_rowconfigure(0, weight=1)
logframe.grid_columnconfigure(0, weight=1)
sb = Scrollbar(logframe)
sb.grid(row=0, column=1, sticky='n s')
logfile = Text(logframe, wrap='word', yscrollcommand=sb.set)
logfile.grid(row=0, column=0, sticky='n s e w')
sb.config(command=logfile.yview)
logframe.pack()
"""b = Button(root, text = "autoscroll", command = callback )
b.pack(side=BOTTOM)
b.config(state = ACTIVE)
"""
termf = Frame(root, height=200, width=500, relief='ridge', bd=2)
termf.pack()
wid = termf.winfo_id()
os.system('urxvt -embed {} -geometry 500x200 -e python3 -i -c "from {} import*" &'.format(wid, sys.argv[1]))
Exemple #41
0
class MiniSedGUI(Frame):

    def __init__(self, master=None):
        Frame.__init__(self, master)

        self.cfg = MiniSedConfig()

        self.source_directory = None
        self.target_directory = None

        self.create_widgets()
        self.pack(anchor=CENTER, fill=BOTH, expand=1)

        self.files_with_content = []

        self.cfg.directory.trace('w', self.disable_apply)
        self.cfg.glob.trace('w', self.disable_apply)
        self.cfg.search.trace('w', self.disable_apply)
        self.cfg.replace.trace('w', self.disable_apply)
        self.cfg.ignore_case.trace('w', self.disable_apply)

    def disable_apply(self, *args):
        self.run_btn["state"] = 'disabled'

    def create_widgets(self):

        self.directory_frame = Frame(self)
        self.directory_frame.pack(side=TOP, fill=X, expand=0, padx=4, pady=4)
        self.directory_frame.grid_columnconfigure(1, weight=1)

        self.directory_label = Label(self.directory_frame, text="Directory:")
        self.directory_label.grid(column=0, row=0)

        self.directory_entry = Entry(self.directory_frame, textvariable=self.cfg.directory)
        self.directory_entry.grid(column=1, row=0, sticky=W + E)
        self.directory_entry.bind('<Return>', lambda arg: self.do_preview())

        self.directory_button = Button(self.directory_frame, text="Browse")
        self.directory_button["command"] = lambda: do_ask_directory(self.cfg.directory)
        self.directory_button.grid(column=2, row=0)

        self.glob_label = Label(self.directory_frame, text="Glob:")
        self.glob_label.grid(column=0, row=1, stick=E)

        self.glob_entry = Entry(self.directory_frame, textvariable=self.cfg.glob)
        self.glob_entry.bind('<Return>', lambda arg: self.do_preview())
        self.glob_entry.grid(column=1, row=1, sticky=N + S + W)

        self.search_replace_frame = Frame(self)
        self.search_replace_frame.grid_columnconfigure(1, weight=1)
        self.search_replace_frame.pack(anchor=N, side=TOP, fill=X, expand=0, padx=4, pady=4)

        self.search_label = Label(self.search_replace_frame, text="Search:")
        self.search_label.grid(column=0, row=0, sticky=E)
        self.search_entry = Entry(self.search_replace_frame, textvariable=self.cfg.search)
        self.search_entry.grid(column=1, row=0, sticky=N + S + W + E)
        self.search_entry.bind('<Return>', lambda arg: self.do_preview())

        self.replace_label = Label(self.search_replace_frame, text="Replace:")
        self.replace_label.grid(column=0, row=1, sticky=E)
        self.replace_entry = Entry(self.search_replace_frame, textvariable=self.cfg.replace)
        self.replace_entry.grid(column=1, row=1, sticky=N + S + W + E)
        self.replace_entry.bind('<Return>', lambda arg: self.do_preview())

        self.option_frame = Frame(self)
        self.option_frame.pack(side=TOP, fill=X, expand=0, pady=4)

        self.work_frame = LabelFrame(self.option_frame, text="Options")
        self.work_frame.pack(side=LEFT, padx=4, pady=4)

        self.ignore_case_checkbutton = Checkbutton(
            self.work_frame, text="ignore case", variable=self.cfg.ignore_case)
        self.ignore_case_checkbutton.pack(side=TOP, anchor=W, expand=0)

        self.create_backups_checkbutton = Checkbutton(
            self.work_frame, text="create backups", variable=self.cfg.create_backups)
        self.create_backups_checkbutton.pack(side=TOP, anchor=W, expand=0)

        self.preview_frame = LabelFrame(self.option_frame, text="Preview")
        self.preview_frame.pack(side=LEFT, padx=4, pady=4)
        self.show_full_content_checkbutton = Checkbutton(
            self.preview_frame, text="show full content", variable=self.cfg.show_full_content)
        self.show_full_content_checkbutton.pack(side=TOP, anchor=W, expand=0)

        self.show_original_checkbutton = Checkbutton(
            self.preview_frame, text="show original", variable=self.cfg.show_original)
        self.show_original_checkbutton.pack(side=TOP, anchor=W, expand=0)

        self.text_frame = Frame(self)
        self.text_frame.pack(side=TOP, fill=BOTH, expand=1, pady=4)

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

        self.scrollbar = Scrollbar(self.text_frame)
        self.scrollbar.grid(column=1, row=0, sticky=N + S)

        self.text = Text(self.text_frame, yscrollcommand=self.scrollbar.set, width=120, height=20)

        self.text.tag_config("file", background="lightgray", foreground="black")
        self.text.tag_config("search", background="lightblue", foreground="black")
        self.text.tag_config("replace", background="orange", foreground="black")
        self.text.tag_config("hollow", foreground="gray")
        self.text.tag_config("highlight", background="lightyellow")

        self.text.config(state=DISABLED)
        self.text.grid(column=0, row=0, sticky=N + S + W + E)
        self.scrollbar.config(command=self.text.yview)

        self.confirm_button_frame = Frame(self)
        self.confirm_button_frame.pack(side=BOTTOM, anchor=E)

        self.cancel_btn = Button(self.confirm_button_frame)
        self.cancel_btn["text"] = "Quit"
        self.cancel_btn["command"] = self.quit
        self.cancel_btn.grid(column=1, row=0, sticky=S, pady=8, padx=8)

        self.preview_btn = Button(self.confirm_button_frame)
        self.preview_btn["text"] = "Preview"
        self.preview_btn["command"] = self.do_preview
        self.preview_btn.grid(column=2, row=0, sticky=S, pady=8, padx=8)

        self.run_btn = Button(self.confirm_button_frame)
        self.run_btn["text"] = "Apply"
        self.run_btn["command"] = self.do_execute
        self.run_btn.grid(column=3, row=0, sticky=S, pady=8, padx=8)
        self.run_btn["state"] = 'disabled'

    def do_preview(self):
        directory = self.cfg.directory.get()

        self.text.config(state=NORMAL)
        self.text.delete("1.0", END)
        self.text.config(state=DISABLED)

        self.files_with_content = []
        for path, dirs, files in os.walk(directory):
            for fname in files:
                filename = os.path.join(path, fname)

                if not self.cfg.glob.get() or fnmatch.fnmatch(fname.lower(), self.cfg.glob.get().lower()):
                    with open(filename, 'rt', encoding='latin-1') as fin:
                        lines = fin.read().splitlines()
                    lines = minised_on_lines(lines, self.cfg.search.get(), self.cfg.replace.get(),
                                             self.cfg.ignore_case.get())
                    self.files_with_content.append((filename, lines))

                    self.text.config(state=NORMAL)
                    self.text.insert(END, "%s:\n" % filename, "file")
                    for line in lines:
                        if isinstance(line, tuple):
                            if self.cfg.show_original.get():
                                self.text.insert(END, "%s" % line[0], "hollow")
                                self.text.insert(END, "%s" % line[1], "search")
                                self.text.insert(END, "%s\n" % line[3], "hollow")

                            self.text.insert(END, "%s" % line[0], "highlight")
                            self.text.insert(END, "%s" % line[2], "replace")
                            self.text.insert(END, "%s" % line[3], "highlight")
                            self.text.insert(END, "\n")
                        elif self.cfg.show_full_content.get():
                            self.text.insert(END, "%s\n" % line)
                    self.text.insert(END, "\n")
                    self.text.config(state=DISABLED)

                    self.master.update()
        self.run_btn["state"] = 'normal'

    def do_execute(self):
        for filename, lines in self.files_with_content:
            if self.cfg.create_backups.get():
                os.rename(filename, filename + "~")

            with open(filename, 'wt', encoding='latin-1', newline='\r\n') as fout:
                for line in lines:
                    if isinstance(line, tuple):
                        fout.write(line[0])
                        fout.write(line[2])
                        fout.write(line[3])
                    else:
                        fout.write(line)
                    fout.write("\n")

        self.run_btn["state"] = 'disabled'
        tkinter.messagebox.showinfo("Replacement successful",
                                    "Replacements have been performed successfully on the files")
Exemple #42
0
class Preferences(Frame):
    def __init__(self, master, valves):
        Frame.__init__(self, master, bg='sky blue', width=1366, height=768)
        self.master = master

        self.canvas = Canvas(self, height=640, width=1300, bg='sky blue')
        self.frame = Frame(self.canvas, bg='sky blue')
        self.frame.bind('<Button-1>', self.process_click_out)

        self.scrollbar = Scrollbar(self, orient='vertical', command=self.canvas.yview)
        self.scrollbar.configure(activebackground='DarkRed', background='red', width=40)
        self.canvas.configure(yscrollcommand=self.scrollbar.set, scrollregion=[0, 0, 1366, 2100])

        self.scrollbar.pack(side='right', fill='y')
        self.canvas.pack(side='left')
        self.canvas.create_window((0, 0), window=self.frame, anchor='nw')

        self.keyboard = Keyboard(self.master)

        self.valves = valves
        self.frame.config(bg='sky blue')
        
        index = 0
        while index < 25:
            self.frame.grid_rowconfigure(index, minsize=80)
            self.frame.grid_columnconfigure(index, minsize=150)
            index += 1

        num_label = [Label(self.frame, text='1'),
                     Label(self.frame, text='2'),
                     Label(self.frame, text='3'),
                     Label(self.frame, text='4'),
                     Label(self.frame, text='5'),
                     Label(self.frame, text='6'),
                     Label(self.frame, text='7'),
                     Label(self.frame, text='8'),
                     ]
        row = 1
        for each in num_label:
            each.grid(row=row, column=0)
            each.config(width=3, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
            row += 3

        text_label = [Label(self.frame, text='VALVE 1:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 2:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 3:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 4:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 5:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 6:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 7:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: '),

                     Label(self.frame, text='VALVE 8:  '),
                     Label(self.frame, text='ACTION A: '),
                     Label(self.frame, text='ACTION B: ')

                     ]
        row = 1
        for each in text_label:
            each.grid(row=row, column=1)
            each.config(width=12, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
            row += 1

        self.valve_label = [Label(self.frame, textvariable=self.valves[0].get_name()),
                            Label(self.frame, textvariable=self.valves[1].get_name()),
                            Label(self.frame, textvariable=self.valves[2].get_name()),
                            Label(self.frame, textvariable=self.valves[3].get_name()),
                            Label(self.frame, textvariable=self.valves[4].get_name()),
                            Label(self.frame, textvariable=self.valves[5].get_name()),
                            Label(self.frame, textvariable=self.valves[6].get_name()),
                            Label(self.frame, textvariable=self.valves[7].get_name())]
        row = 1 
        for each in self.valve_label:
            each.grid(row=row, column=2)
            each.config(width=12, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4', anchor='w')
            each.bind('<Button-1>', self.process_click_out)
            row += 3

        self.entry_field = [Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),

                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),

                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text=''),
                            Entry(self.frame, text='')
                            ]
        row = 1
        for each in self.entry_field:
            each.grid(row=row, column=3)
            each.config(width=12, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4')
            each.bind('<Button-1>', self.process_click_in)
            row += 1

        self.action_a_label = [Label(self.frame, textvariable=self.valves[0].get_action_a()),
                               Label(self.frame, textvariable=self.valves[1].get_action_a()),
                               Label(self.frame, textvariable=self.valves[2].get_action_a()),
                               Label(self.frame, textvariable=self.valves[3].get_action_a()),
                               Label(self.frame, textvariable=self.valves[4].get_action_a()),
                               Label(self.frame, textvariable=self.valves[5].get_action_a()),
                               Label(self.frame, textvariable=self.valves[6].get_action_a()),
                               Label(self.frame, textvariable=self.valves[7].get_action_a())
                               ]
        row = 2
        for each in self.action_a_label:
            each.grid(row=row, column=2)
            each.config(width=12, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4', anchor='w')
            each.bind('<Button-1>', self.process_click_out)
            row += 3

        self.action_b_label = [Label(self.frame, textvariable=self.valves[0].get_action_b()),
                               Label(self.frame, textvariable=self.valves[1].get_action_b()),
                               Label(self.frame, textvariable=self.valves[2].get_action_b()),
                               Label(self.frame, textvariable=self.valves[3].get_action_b()),
                               Label(self.frame, textvariable=self.valves[4].get_action_b()),
                               Label(self.frame, textvariable=self.valves[5].get_action_b()),
                               Label(self.frame, textvariable=self.valves[6].get_action_b()),
                               Label(self.frame, textvariable=self.valves[7].get_action_b())
                               ]

        row = 3
        for each in self.action_b_label:
            each.grid(row=row, column=2)
            each.config(width=12, font=('Lucida Console', 30), bg='sky blue', fg='RoyalBlue4', anchor='w')
            each.bind('<Button-1>', self.process_click_out)
            row += 3

        self.lock()

    def process_click_out(self, event):
        self.canvas.configure(height=660)
        self.keyboard.grid_forget()

    def process_click_in(self, event):
        index = 0
        for each in self.entry_field:
            if each == event.widget:
                break
            index += 1

        if event.widget.cget('state') == 'normal':
            self.canvas.configure(height=250)
            self.keyboard.grid(row=2, column=0)
            self.keyboard.set_entry(event.widget)
            self.canvas.yview_moveto(index / 28)

    def lock(self):
        for each in self.entry_field:
            each.config(state='disabled')