Beispiel #1
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'))
Beispiel #2
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
Beispiel #3
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'))
    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)
 def _button_block(self):
     ''' Метод отрисовывает кнопки '''
     bottom_frame = Frame(self)
     bottom_frame.pack(side="bottom", fill="x")
     bottom_frame.grid_columnconfigure(0, weight=1)
     bottom_frame.grid_columnconfigure(1, weight=1)
     bottom_frame.grid_columnconfigure(2, weight=1)
     btn_1 = Button(bottom_frame,
                    text="Новый",
                    command=self._generate_question)
     btn_1.grid(pady=0, padx=2, row=1, column=0, sticky="we")
     btn_2 = Button(bottom_frame,
                    text="Проверить",
                    command=self.check_answer)
     btn_2.grid(pady=0, padx=2, row=1, column=1, sticky="we")
     btn_3 = Button(bottom_frame, text="Ответ", command=self.get_answer)
     btn_3.grid(pady=0, padx=2, row=1, column=2, sticky="we")
Beispiel #6
0
def _connect_home_and_q_and_a_frames(home_frame: tkinter.Frame,
                                     q_and_a_frame: tkinter.Frame) -> None:
    q_type_checkbuttons: typing.List[tkinter.ttk.Checkbuttons] = []
    q_type_indexed_q_and_a_generators: typing.Dict[
        str, MM_QAndAGenerators.
        Q_AND_A_GENERATOR_SIGNATURE] = MM_QAndAGenerators.get_q_type_indexed_generators(
        )

    cur_home_frame_checkbutton_row: int = 0
    cur_home_frame_checkbutton_col: int = 0
    for (q_index, q_type) in enumerate(q_type_indexed_q_and_a_generators):
        cur_home_frame_checkbutton_row += q_index // 2
        cur_home_frame_checkbutton_col += q_index % 2

        home_frame.grid_rowconfigure(cur_home_frame_checkbutton_row, weight=1)
        home_frame.grid_columnconfigure(cur_home_frame_checkbutton_col,
                                        weight=1)

        q_type_checkbutton: tkinter.ttk.Checkbutton = tkinter.ttk.Checkbutton(
            master=home_frame,
            text=q_type,
        )
        q_type_checkbutton.state(["!alternate"])
        q_type_checkbutton.grid(row=cur_home_frame_checkbutton_row,
                                column=cur_home_frame_checkbutton_col,
                                sticky="nsew")

        q_type_checkbuttons.append(q_type_checkbutton)

    home_frame_start_btn: tkinter.Button = tkinter.Button(
        master=home_frame,
        text="Start",
        command=lambda: _activate_frame(q_and_a_frame))
    home_frame_start_btn.grid(row=cur_home_frame_checkbutton_row + 1,
                              column=0,
                              columnspan=2)

    (q_and_a_frame_q_textbox,
     q_and_a_frame_a_textbox) = q_and_a_frame.winfo_children()

    show_q_or_a: typing.Callable[
        [tkinter.Event], None] = lambda event: _show_q_or_a(
            q_and_a_frame_a_textbox, q_and_a_frame_q_textbox,
            q_type_checkbuttons, q_type_indexed_q_and_a_generators)
    q_and_a_frame.bind("<space>", show_q_or_a)
    q_and_a_frame.bind("<Escape>", lambda event: _activate_frame(home_frame))
Beispiel #7
0
 def __init__(self, *args, **kwargs):
     """
     Initializing the initail tkinter application.
     """
     Tk.__init__(self, *args, **kwargs)
     self.title("swiss style Tournament")
     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 (StartPage, ContinuePage, InitialPage, PlayerRoundPage,
               MatchPage, OverPage):
         frame = F(container, self)
         self.frames[F] = frame
         frame.grid(row=0, column=0, sticky="nsew")
     self.showFrame(StartPage)
Beispiel #8
0
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)
        self.title("Pong")
        self.geometry(f"{self.window_width}x{self.window_height}")
        self.resizable(0, 0)
        container = Frame(self, bg="black")
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)
        self.center()

        self.frames = {}
        for F in (MainMenu, Game):
            page_name = F.__name__
            frame = F(parent=container, controller=self)
            self.frames[page_name] = frame
        self.frames["MainMenu"].grid()
    def image_frame(parent):
        frame = Frame(parent.building_pos_window, width=640, height=360)
        frame.grid_rowconfigure(0, weight=1)
        frame.grid_columnconfigure(0, weight=1)
        frame.grid_propagate(False)
        frame.grid(row=0, column=0, sticky=N + W)

        label = Label(frame,
                      text='Loading city image, Please wait!',
                      background='white')
        label.grid(row=0, column=0, sticky=NSEW)

        canvas = Canvas(frame, width=640, height=360)

        def setBuildingCoords(event):
            if selected_building['name'] is None:
                return
            pos = [event.x * 2, event.y * 2]
            if parent.bot_building_pos is None:
                parent.bot_building_pos = {}

            parent.bot_config.hasBuildingPos = True
            parent.bot_building_pos[selected_building['name']] = [
                pos[0], pos[1]
            ]
            write_building_pos(parent.bot_building_pos,
                               parent.device.serial.replace(':', "_"))
            selected_building['label'].config(
                text='[{}, {}]'.format(pos[0], pos[1]))
            selected_building['name'] = None
            selected_building['label'] = None

        canvas.bind("<Button 1>", setBuildingCoords)

        def after_image_load():
            image = parent.bot.get_city_image().resize((640, 360),
                                                       Image.ANTIALIAS)
            frame.image = image = ImageTk.PhotoImage(image)
            canvas.create_image((0, 0), image=image, anchor='nw')
            parent.bot.curr_thread = None
            label.grid_forget()
            canvas.grid(row=0, column=0, sticky=N + W)

        parent.bot.start(after_image_load)

        return frame
Beispiel #10
0
    def __init__(self, *args, **kw):
        Toplevel.__init__(self)
        container = Frame(self, bg=globals.BOARD_COLOR.get())
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.title('Snak Settings')

        self.frames = {}
        for F in (StartPage, ColorPage):
            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("StartPage")
Beispiel #11
0
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)
        Tk.config(self, bg=bg)
        self.SeatNum = StringVar()
        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=False)
        fileMenu.add_command(
            label='Save Settings',
            command=lambda: self.popupmsg('Not Supported Yet.'))
        fileMenu.add_separator()
        fileMenu.add_command(label='Close', command=quit)
        graphMenu = Menu(menuBar, tearoff=False)
        graphMenu.add_command(label='Bar', )
        graphMenu.add_command(label='Pie', )
        graphMenu.add_command(label='line', )
        graphMenu.add_command(label='Export as PDF', command=self.PDF_Creator)
        CollegeMenu = Menu(menuBar, tearoff=False)
        CollegeMenu.add_command(
            label='Info', command=lambda: op('http://nmfdegree.edu.in/#'))
        HelpBar = Menu(menuBar, tearoff=False)
        HelpBar.add_command(label='Tutorial',
                            command=lambda: op('Tutorial Page V2.html'))
        menuBar.add_cascade(label='File', menu=fileMenu)
        menuBar.add_cascade(label='Graph', menu=graphMenu)
        menuBar.add_cascade(label='Info', menu=CollegeMenu)
        menuBar.add_cascade(label='Help', menu=HelpBar)
        Tk.config(self, menu=menuBar)

        DT = ttk.Style()
        DT.configure('TButton',
                     foreground='black',
                     borderwidth=1,
                     focusthickness=3,
                     focuscolor='none')
        DT.map('TButton', background=[('active', 'red')])
        self.frames = {}
        for F in (StartPage, StudOptionFrame, StudentORTeacher,
                  TchrOptionFrame):
            frame = F(container, self)
            self.frames[F] = frame
            frame.grid(row=0, column=0, sticky='nsew')
        self.show_frame(StartPage)
Beispiel #12
0
    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')
Beispiel #13
0
class ViewContainer(Tk):
    class Constants:
        center = N + S + E + W

    def __init__(self):
        super().__init__()
        self.__container = Frame(self)
        self.__container.pack()
        self.__container.grid_rowconfigure(0, weight=1)
        self.__container.grid_columnconfigure(0, weight=1)

    @property
    def container (self):
        return self.__container

    def set_views (self, views):
        for views in views:
            views.grid(row=0, column=0, sticky= self.Constants.center)
def init_volume_display_gui(frame):
    # tytuł sekcji
    title = Label(frame, text="Volume", font=font.Font(size=20))
    title.grid(column=0, row=0)

    # kontener na ledy
    leds_frame = Frame(frame)
    leds_frame.grid(column=0, row=1)

    # tworzenie i ustawianie ledów
    for col in range(8):
        led = Label(leds_frame, text='', width=2, height=1, bg=TURN_OFF_COLOR)
        led.grid(column=col, row=1)
        volume_leds.append(led)
        leds_frame.grid_columnconfigure(col, minsize=40)

    # pierwsze wywołanie
    set_volume_leds(show_mixer())
Beispiel #15
0
class SensorView(AbstractModule):
    name = "Sensor View"

    def __init__(self, root):
        super().__init__(root, FRAME_CONFIG)

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

        self.mode_selector_frame = Frame(self, FRAME_CONFIG)
        self.mode_selector_frame.grid(row=0, column=0, sticky='nswe')
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self.mode_selectors = {}  # holds buttons at one of SENSOR_VIEW_MODES
        self.modes = {}  # holds instances of SENSOR_VIEW_MODES

        for counter, Mode in enumerate(SENSOR_VIEW_MODES):
            self.mode_selectors[Mode] = Button(
                self.mode_selector_frame,
                text=Mode.__name__,
                cnf=BUTTON_CONFIG,
                command=lambda Mode=Mode: self.enable_mode(Mode))
            self.mode_selectors[Mode].grid(row=0,
                                           column=counter,
                                           sticky='nswe')
            self.mode_selector_frame.grid_columnconfigure(counter, weight=1)
            self.mode_selector_frame.grid_rowconfigure(0, weight=1)

            self.modes[Mode] = Mode(self)
            self.modes[Mode].grid(row=1, column=0, sticky='nswe')

        self.active_mode = self.modes[SENSOR_VIEW_MODES[0]]
        self.enable_mode(SENSOR_VIEW_MODES[0])

    def enable_mode(self, mode):
        self.mode_selectors[type(
            self.active_mode)].configure(bg=BUTTON_COLOR_INACTIVE)
        self.modes[mode].tkraise()
        self.active_mode = self.modes[mode]
        self.mode_selectors[mode].configure(bg=BUTTON_COLOR_ACTIVE)

    def refresh(self):
        self.active_mode.refresh()
Beispiel #16
0
def score_board():
    global entry_match, entry_X, entry_O
    score_board = Frame(main_frame, bg="dark slate gray")

    label_score = Label(score_board,
                        text="Score",
                        font=("Arial", 12),
                        bg="dark slate gray",
                        fg="white")
    label_X = Label(score_board,
                    text="X: ",
                    font=("Arial", 12),
                    bg="dark slate gray",
                    fg="white")
    label_O = Label(score_board,
                    text="O: ",
                    font=("Arial", 12),
                    bg="dark slate gray",
                    fg="white")
    label_match = Label(score_board,
                        text="Match: ",
                        font=("Arial", 12),
                        bg="dark slate gray",
                        fg="white")

    label_score.grid(row=0, column=0, sticky="nsew")
    label_X.grid(row=0, column=1, sticky="nsew")
    label_O.grid(row=0, column=3, sticky="nsew")
    label_match.grid(row=0, column=5, sticky="nsew")

    entry_X = Label(score_board, width=10, text="0", bg="#ffffff")
    entry_O = Label(score_board, width=10, text="0", bg="#ffffff")
    entry_match = Label(score_board, width=12, text="", bg="#ffffff")

    entry_X.grid(row=0, column=2, padx=(0, 10), sticky="nsew")
    entry_O.grid(row=0, column=4, padx=(0, 10), sticky="nsew")
    entry_match.grid(row=0, column=6, padx=(0, 10), sticky="nsew")

    score_board.pack(fill="both", pady=(5, 10))

    score_board.grid_columnconfigure(0, weight=1)
    score_board.grid_columnconfigure(2, weight=1)
    score_board.grid_columnconfigure(4, weight=1)
    score_board.grid_columnconfigure(6, weight=1)
Beispiel #17
0
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)
        Tk.wm_title(self, "Wave Energetics")

        container = Frame(self, background="red")
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)
        self.geometry("666x800")
        self.frames = {}
        for F in (StartPage, PageOne, SimPage):

            frame = F(container, self)

            self.frames[F] = frame

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

        self.show_frame(StartPage)
Beispiel #18
0
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)

        Tk.wm_title(self, 'Obesity')

        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 (HomePage, WORLD, USA, EU, POLAND):
            frame = F(container, self)
            self.frames[F] = frame

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

        self.show_frame(HomePage)
 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
     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 _create_widgets(self, curr_mode):
     self.grid_rowconfigure(0, weight=1)
     self.grid_rowconfigure(1, weight=0)
     self.grid_columnconfigure(0, weight=1)
             
     frame = Frame(self)
     frame.grid(row=0, column=0, sticky=tk.NSEW)
     
     frame.grid_columnconfigure(0, weight=1, uniform="fred")
     frame.grid_columnconfigure(1, weight=1, uniform="fred")
     frame.grid_rowconfigure(0, weight=1, uniform="wilma")
     frame.grid_rowconfigure(1, weight=1, uniform="wilma")
     
     font_large = ("Helvetica", 16)
     font_small = ("Helvetica", 14)
     
     text = "Extend"
     if curr_mode == Mode.Extend:
         text += " (CURRENT)"
     extend = Button(frame, text=text, command=self.set_extended, font=font_large)
     extend.grid(row=0, column=0, sticky=tk.NSEW)
     
     text = "Duplicate"
     if curr_mode == Mode.Duplicate:
         text += " (CURRENT)"
     duplicate = Button(frame, text=text, command=self.set_duplicated, font=font_large)
     duplicate.grid(row=0, column=1, sticky=tk.NSEW)
     
     text = "Left TV"
     if curr_mode == LeftTV:
         text += " (CURRENT)"
     left_monitor = Button(frame, text=text, command=self.set_left_screen, font=font_large)
     left_monitor.grid(row=1, column=0, sticky=tk.NSEW)
     
     text = "Right TV"
     if curr_mode == RightTV:
         text += " (CURRENT)"
     right_monitor = Button(frame, text=text, command=self.set_right_screen, font=font_large)
     right_monitor.grid(row=1, column=1, sticky=tk.NSEW)
     
     cancel = Button(self, text='Cancel', command=self.cancel, font=font_small)
     cancel.grid(row=1, column=0, sticky=tk.SE)
Beispiel #21
0
    def create_page(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 F in (status.RunPage, setting.SettingPage, mannual.HowToUsePage):
            page_name = F.__name__
            frame = F(parent=container, controller=self)
            self.frames[page_name] = frame
            """
            put all of the utils 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")

        # 设置主菜单
        menu = Menu(self)

        # 设置子菜单
        submenu = Menu(menu, tearoff=0)
        submenu.add_command(label="设置", command=self.settings)
        menu.add_cascade(label="设置", menu=submenu)

        # 预约子菜单
        submenu = Menu(menu, tearoff=0)
        submenu.add_command(label="自动预约", command=self.auto_appointmant)
        menu.add_cascade(label="自动预约", menu=submenu)

        # 帮助子菜单
        submenu = Menu(menu, tearoff=0)
        submenu.add_command(label="使用说明", command=self.how_to_use)
        submenu.add_command(label="关于", command=self.about)
        menu.add_cascade(label="帮助", menu=submenu)

        self.config(menu=menu)

        # 起始界面
        self.show_frame("SettingPage")
        self.Ck.daemon = True
        self.Ck.start()
Beispiel #22
0
class SampleApp(Tk):
    def __init__(self):
        super().__init__()

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

        #menuAdicionar
        menuAdicionar = Menu(menubar, tearoff=0)
        menubar.add_cascade(label="Adicionar", menu=menuAdicionar)

        menuAdicionar.add_command(
            label="Usuário", command=lambda: self.showFrame("TelaUsuario"))
        menuAdicionar.add_command(
            label="Cliente", command=lambda: self.showFrame("TelaCliente"))

        #container
        #onde os frames vaão ficar um em cima do outro.
        self.container = Frame(self, width=300, bg="blue")
        self.container.grid_rowconfigure(0, weight=1)
        self.container.grid_columnconfigure(0, weight=1)

        #um dicionario com todos os frames.
        self.frames = {}
        #percorrer todos os frames.
        for classe in (TelaUsuario, TelaCliente):
            page_name = classe.__name__
            frame = classe(parent=self.container, width=500)
            #atualizando o dicionario
            self.frames[page_name] = frame
            #colocando os frames no mesmo local.
            frame.grid(row=0, column=0, sticky="nsew")

        #pack
        self.container.pack(side="left", fill="y", padx=5, pady=5)
        self.container.pack_propagate(False)

    #atulizar o frame que ficará 'na frente' dos outros.
    def showFrame(self, page_name):
        frame = self.frames[page_name]
        frame.tkraise()
Beispiel #23
0
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)

        Tk.wm_title(self, 'My title')

        container = Frame(self)  # funny thing which does sth
        container.pack(side='top', fill='both', expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        self.frames = {}  # dictionary with all frames

        for F in (HomePage,
                  PageOne):  # a for loop to add all frames to self.frames
            frame = F(container, self)
            self.frames[F] = frame

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

        self.show_frame(HomePage)
Beispiel #24
0
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)
        self.grid_rowconfigure(0, weight=1)
        self.grid_columnconfigure(0, weight=1)

        main_container = Frame(self)
        main_container.grid(column=0, row=0, sticky='nesw')
        main_container.grid_rowconfigure(0, weight=1)
        main_container.grid_columnconfigure(0, weight=1)

        self.frames = {}

        for frame_class in (StartPage, ClaimPage, StancePage):
            frame = frame_class(main_container, self)

            self.frames[frame_class] = frame

            frame.grid(row=0, column=0, sticky="nsew", padx=20, pady=20)

        self.show_frame(StartPage)
Beispiel #25
0
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)
        self.is_fullscreen = True
        self.wm_attributes("-fullscreen", self.is_fullscreen)

        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 name in (
                "idle",
                "screaming",
                "fail",
                "success",
                "choice",
                "publishing",
                "bug",
        ):
            frame = Screen(
                parent=container,
                controller=self,
                width=self.screen["width"],
                height=self.screen["height"],
                name=name,
            )
            self.frames[name] = frame
            frame.grid(row=0, column=0, sticky="nsew")

        self.show_idle()
        self.bind("<a>", self.show_idle)
        self.bind("<z>", self.show_screaming)
        self.bind("<e>", self.show_fail)
        self.bind("<r>", self.show_success)
        self.bind("<t>", self.show_choice)
        self.bind("<y>", self.show_publishing)
        self.bind("<u>", self.show_bug)

        self.bind("<f>", self.toggle_fullscreen)
        self.config(cursor="none")
Beispiel #26
0
class App(Tk):
    def __init__(self, *args, **kwargs):
        Tk.__init__(self)
        Tk.title(self, "Bibeto's App")
        self.geometry("620x260+30+0")

        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.protocol("WM_DELETE_WINDOW", lambda: self.exit_handler())

    def show_frame(self, frame):
        frame.tkraise()

        menu = frame.menu_bar(self)

    def exit_handler(self):
        if messagebox.askokcancel("Bibeto's app", "Sure you want to quit ?"):
            self.destroy()
	def __init__(self, *arg, **kwargs):
		# global billetera
		Tk.__init__(self, *arg, **kwargs)
		container = Frame(self)
		container.pack(side = "top", fill = "both", expand = 1)

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

		self.frames = {}
		

		for i in (Lobby, Game, Info, Shop, Craft, Bank, BackPack, Pet_zone):

			frame = i(container, self)

			self.frames[i] = frame

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

		self.show_frame(Lobby)
Beispiel #28
0
class App(Tk):
    def __init__(self, *args, **kwargs):
        Tk.__init__(self, *args, **kwargs)

        self.container = Frame(self)

        if DEBUG:
            self.iconbitmap(resource_path(r'assets\anieGrabberIcon.ico'))
        else:
            self.iconbitmap(resource_path(r'anieGrabberIcon.ico'))

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

        self.frames = {}

        for F in [mainPage, autoPage, manualPage]:
            frame = F(self.container, self)
            self.frames[F] = frame
            frame.grid(row=0, column=0, sticky='nsew')

        self.loadPage(mainPage, 280, 461)

    def loadPage(self, page, width, height):

        self.geometry('{}x{}'.format(width, height))
        x = int(self.winfo_screenwidth() / 2 - width / 2)
        y = int(self.winfo_screenheight() / 3 - height / 2)
        self.geometry('+{}+{}'.format(x, y))
        self.minsize(width, height)

        self.showFrame(page)

    def showFrame(self, context):

        frame = self.frames[context]
        frame.tkraise()
Beispiel #29
0
def update_accidents_table():
    for widget in accidents_tab.winfo_children():
        widget.destroy()
    headers = ['Cars', 'Lap', 'Session', '', '']

    scrollbar = Scrollbar(accidents_tab, orient='vertical')
    scrollbar.grid(row=0, column=1, sticky='ns')

    canvas = Canvas(accidents_tab, yscrollcommand=scrollbar.set)
    canvas.create_image(0, 0, anchor='ne')
    canvas['scrollregion'] = (0, 0, 0, (len(listed_accidents) + 1) * 30)
    canvas['width'] = 565
    canvas['height'] = 370
    canvas.grid(row=0, column=0)

    scrollbar.config(command=canvas.yview)
    canvas.config(scrollregion=canvas.bbox("all"))

    table = Frame(canvas)

    for j, column in enumerate(headers):
        label = Label(table,
                      text=column,
                      width=15,
                      height=2,
                      font='Helvetica 8 bold')
        label.grid(row=0, column=j, sticky="nsew", padx=1, pady=1)
        table.grid_columnconfigure(j, weight=1)
    for i, row in enumerate(listed_accidents):
        for j, column in enumerate(row):
            label = Label(table, text=column, bg='Light Gray', height=1)
            label.grid(row=i + 1, column=j, sticky="nsew", padx=1, pady=1)
            table.grid_columnconfigure(j, weight=1)
            if j == 2:
                dismiss_button = Button(
                    table,
                    text="Racing Incident",
                    bg='medium sea green',
                    width=5,
                    command=lambda row=i: dismiss_accident(row))
                penalty_button = Button(table,
                                        text="Penalty",
                                        bg='indian red',
                                        width=5,
                                        command=lambda row=i: add_penalty(row))

                dismiss_button.grid(row=i + 1,
                                    column=j + 1,
                                    padx=1,
                                    pady=1,
                                    sticky="nsew")
                penalty_button.grid(row=i + 1,
                                    column=j + 2,
                                    padx=1,
                                    pady=1,
                                    sticky="nsew")
                table.grid_columnconfigure(j + 1, weight=1)

    canvas.create_window((0, 0), window=table, anchor='nw')
Beispiel #30
0
    def populate_with_departures(self, departure_B, departure_A):
        depFrame = Frame(self.departuresFrame)
        #specifies "self.font" for time/clock
        self.font = tkFont.Font(family="helvetica", size=18)
        #specifies for all belonging to TextFont (other types: TkDefaultFont, TkTextFont, TkFixedFont)
        self.default_font = tkFont.nametofont("TkTextFont")
        self.default_font.configure(size=14)
        # bold for "in min"
        self.in_min_font = tkFont.Font(size=14, weight='bold')

        depFrame.grid_columnconfigure(1, weight=2)

        self.time_label = Label(self.master,
                                font=self.font,
                                text="Current time: " +
                                now)  # .strftime('%H:%M'))
        self.time_label.grid(row=0, column=0, columnspan=2, sticky=W)

        self.update_button = Button(self.master,
                                    text="Shutdown",
                                    command=self.update)
        self.update_button.grid(row=0, column=2, columnspan=2, sticky=E)

        # label colums
        self.label_columns("<- Direction <-", 1)
        # departures on track A
        self.departure_rows(departure_B, 0)

        # SPACE between directions CODE
        self.spacer = Label(self.master, width=sum(widths) + 2)
        self.spacer.grid(row=2 + len(departure_B), column=0, columnspan=7)

        # label colums
        self.label_columns("-> Direction ->", 3 + len(departure_B))
        # departures on track B
        self.departure_rows(departure_A, 4 + len(departure_B))

        # Add the newly created frame to a list so we can destroy it later when we refresh the departures
        self.departureRowFrames.append(depFrame)
Beispiel #31
0
    def __init__(self):

        tk.Tk.__init__(self)

        self.wm_title("SimonSays")  # Sets the Title of our window

        FrameMan = Frame(
            self, background="green"
        )  # Can set an outline or background color if want. it shouldn't really be seen.
        FrameMan.pack(
            fill="both",
            expand=1)  #Fill the slot its in. The window only have 1 slot

        # FrameMan = Frame Manager or the guy who decides which screen will show in the window

        FrameMan.grid_rowconfigure(0, weight=1)
        FrameMan.grid_columnconfigure(
            0, weight=1)  # makes this frame adjust to the size of the window.

        self.pages = {}  # a dic of all the pages in our program

        #TODO: Add Settings Page
        #TODO: Statistics Page?

        self.Frames = (
            SimonSays,
            MainMenu,
            Lost,
        )

        for page in self.Frames:  # must add new menus here...
            vpage = page(FrameMan, self)  # Calls and creates the page

            self.pages[
                page] = vpage  # Stores an instance of that page in the dict so it can be referenced again

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

        self.Show_Page(MainMenu)
Beispiel #32
0
def print_table():
    global tab1
    n = int(nombre_arc_entry.get())
    global frame2
    frame2 = Frame(left_side_container)
    frame2['bg'] = _BACKGROUNDCOLOR
    frame2.pack(fill="both")
    tablayout = Notebook(frame2)
    tab1 = Frame(tablayout)
    tab1['bg'] = _BACKGROUNDCOLOR
    tab1.pack(fill="both")

    for row in range(n+1):
        for column in range(3):
            if row == 0 :
                if column == 1:
                    label = Label(tab1, text="Nœud A ")
                    label.config(font=('Arial', 14))
                    label['bg']=_BACKGROUNDCOLOR_VARIANT
                    label.grid(row=row, column=column, sticky="nsew", padx=1, pady=1)
                    tab1.grid_columnconfigure(column, weight=1)
                if column == 2:
                    label = Label(tab1, text="Nœud B ")
                    label.config(font=('Arial', 14))
                    label['bg']=_BACKGROUNDCOLOR_VARIANT
                    label.grid(row=row, column=column, sticky="nsew", padx=1, pady=1)
                    tab1.grid_columnconfigure(column, weight=1)
            
            else:
                if column == 0:
                    label = Label(tab1, text="Transition : " + str(row))
                    label.config(font=('Arial', 14))
                    label['bg']=_BACKGROUNDCOLOR_VARIANT
                    label.grid(row=row, column=column, sticky="nsew", padx=1, pady=1)
                    tab1.grid_columnconfigure(column, weight=1)
                else:
                    label = Entry(tab1, text="Row : " + str(row) + " , Column : " + str(column))
                    label.grid(row=row, column=column, sticky="nsew", padx=1, pady=1)
                    tab1.grid_columnconfigure(column, weight=1)


    tablayout.pack(fill="both")
    calc = Button(frame2, text="Générer le Graph", command =get_values)
    calc.pack(padx = 20, pady = 20)

    reset = Button(frame2, text = "Reset" , command = reset_table)
    reset.pack(padx = 5, pady = 5)
    return tab1
    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_rowconfigure(3, 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)

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

        self.caller_id_text = StringVar(value="caller_id_text")
        self.duration_text = StringVar(value="00:00:00")

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

        duration_label = Label(frame, textvariable=self.duration_text)
        duration_label.grid(row=2, column=0, sticky="n")

        self.hangup_button = Button(frame,
                                    image=load_image(self, "hangup.png"),
                                    relief="flat")
        self.hangup_button.grid(row=3, column=0, sticky="nsew")
Beispiel #34
0
    def __init__(self, predictor):
        Tk.__init__(self)
        container = Frame(self)
        container.pack(side="top", fill="both", expand=True)
        container.grid_rowconfigure(0, weight=1)
        container.grid_columnconfigure(0, weight=1)

        # global variables for different pages.
        self.predictor = predictor
        self.im = None
        self.label = None
        self.heatmap = None
        self.segmentation= None

        # Set pages.
        # Set start page.
        self.frames = {}
        for F in (TitlePage,ImagePage, ResultPage,SegmentPage):
            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("TitlePage") 
def init_take_actions_gui(frame, serial_port):
    """Tworzy interfejs graficzny do zadania"""

    # tytuł sekcji
    title = Label(frame, text="Actions on host", font=font.Font(size=20))
    title.grid(column=0, row=0)

    # kontener na ledy
    actions_frame = Frame(frame)
    actions_frame.grid(column=0, row=1)

    ACTION_CODES = [
        "3",  # przeglądarka WWW
        "12",  # edytor tekstu Vi
        "48",  # program mc
        "192",  # nowy terminal
        "15",  # kalendarz
        "60",  # wybrane polecenie/skrypt w terminalu
        "240",  # wybrane polecenie/skrypt w terminalu
        "195",  # wybrane polecenie/skrypt w terminalu
    ]

    # funkcje wyzawalane naciśnięciem przycisku wysłanie portem serialowym właściwej wartości
    def sender_helper(action_number):
        serial_port.write(b"zad4")
        serial_port.write(action_number.encode())

    # tworzenie i ustawianie ledów
    for col in range(8):
        # light = Label(actions_frame, text='S'+str(col+1), width=2, height=1, bg=TURN_OFF_COLOR)
        light = Button(text='S' + str(col + 1),
                       command=partial(sender_helper, ACTION_CODES[col]),
                       background=TURN_ON_COLOR)
        # light.grid(column=col, row=1)
        light.place(x=200 + col * 40, y=355)
        actions_lights.append(light)
        actions_frame.grid_columnconfigure(col, minsize=40)
Beispiel #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
Beispiel #37
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")
Beispiel #38
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')
Beispiel #39
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')
Beispiel #40
0
    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]))
Beispiel #41
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)
Beispiel #42
0
class InstanceEditor(Toplevel):

    def __init__(self):
        Toplevel.__init__(self)
        self.focus_set()
        self.grab_set()

        self.result = None
        self.module_data = None
        self.mod_applis = None
        self.title(ugettext("Instance editor"))
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)

        self.ntbk = ttk.Notebook(self)
        self.ntbk.grid(row=0, column=0, columnspan=1, sticky=(N, S, E, W))

        self.frm_general = Frame(self.ntbk, width=350, height=150)
        self.frm_general.grid_columnconfigure(0, weight=0)
        self.frm_general.grid_columnconfigure(1, weight=1)
        self._general_tabs()
        self.ntbk.add(self.frm_general, text=ugettext('General'))

        self.frm_database = Frame(self.ntbk, width=350, height=150)
        self.frm_database.grid_columnconfigure(0, weight=0)
        self.frm_database.grid_columnconfigure(1, weight=1)
        self._database_tabs()
        self.ntbk.add(self.frm_database, text=ugettext('Database'))

        btnframe = Frame(self, bd=1)
        btnframe.grid(row=1, column=0, columnspan=1)
        Button(btnframe, text=ugettext("OK"), width=10, command=self.apply).grid(
            row=0, column=0, sticky=(N, S, E))
        Button(btnframe, text=ugettext("Cancel"), width=10, command=self.destroy).grid(
            row=0, column=1, sticky=(N, S, W))

    def _database_tabs(self):
        Label(self.frm_database, text=ugettext("Type")).grid(
            row=0, column=0, sticky=(N, W), padx=5, pady=3)
        self.typedb = ttk.Combobox(
            self.frm_database, textvariable=StringVar(), state=READLONY)
        self.typedb.bind("<<ComboboxSelected>>", self.typedb_selection)
        self.typedb.grid(row=0, column=1, sticky=(N, S, E, W), padx=5, pady=3)
        Label(self.frm_database, text=ugettext("Name")).grid(
            row=1, column=0, sticky=(N, W), padx=5, pady=3)
        self.namedb = Entry(self.frm_database)
        self.namedb.grid(row=1, column=1, sticky=(N, S, E, W), padx=5, pady=3)
        Label(self.frm_database, text=ugettext("User")).grid(
            row=2, column=0, sticky=(N, W), padx=5, pady=3)
        self.userdb = Entry(self.frm_database)
        self.userdb.grid(row=2, column=1, sticky=(N, S, E, W), padx=5, pady=3)
        Label(self.frm_database, text=ugettext("Password")).grid(
            row=3, column=0, sticky=(N, W), padx=5, pady=3)
        self.pwddb = Entry(self.frm_database)
        self.pwddb.grid(row=3, column=1, sticky=(N, S, E, W), padx=5, pady=3)

    def _general_tabs(self):
        Label(self.frm_general, text=ugettext("Name")).grid(
            row=0, column=0, sticky=(N, W), padx=5, pady=3)
        self.name = Entry(self.frm_general)
        self.name.grid(row=0, column=1, sticky=(N, S, E, W), padx=5, pady=3)
        Label(self.frm_general, text=ugettext("Appli")).grid(
            row=1, column=0, sticky=(N, W), padx=5, pady=3)
        self.applis = ttk.Combobox(
            self.frm_general, textvariable=StringVar(), state=READLONY)
        self.applis.bind("<<ComboboxSelected>>", self.appli_selection)
        self.applis.grid(row=1, column=1, sticky=(N, S, E, W), padx=5, pady=3)
        Label(self.frm_general, text=ugettext("Modules")).grid(
            row=2, column=0, sticky=(N, W), padx=5, pady=3)
        self.modules = Listbox(self.frm_general, selectmode=EXTENDED)
        self.modules.configure(exportselection=False)
        self.modules.grid(row=2, column=1, sticky=(N, S, E, W), padx=5, pady=3)
        Label(self.frm_general, text=ugettext("Language")).grid(
            row=3, column=0, sticky=(N, W), padx=5, pady=3)
        self.language = ttk.Combobox(
            self.frm_general, textvariable=StringVar(), state=READLONY)
        self.language.grid(
            row=3, column=1, sticky=(N, S, E, W), padx=5, pady=3)
        Label(self.frm_general, text=ugettext("CORE-connectmode")
              ).grid(row=4, column=0, sticky=(N, W), padx=5, pady=3)
        self.mode = ttk.Combobox(
            self.frm_general, textvariable=StringVar(), state=READLONY)
        self.mode.bind("<<ComboboxSelected>>", self.mode_selection)
        self.mode.grid(row=4, column=1, sticky=(N, S, E, W), padx=5, pady=3)
        Label(self.frm_general, text=ugettext("Password")).grid(
            row=5, column=0, sticky=(N, W), padx=5, pady=3)
        self.password = Entry(self.frm_general, show="*")
        self.password.grid(
            row=5, column=1, sticky=(N, S, E, W), padx=5, pady=3)

    def typedb_selection(self, event):

        visible = list(self.typedb[VALUES]).index(self.typedb.get()) != 0
        for child_cmp in self.frm_database.winfo_children()[2:]:
            if visible:
                child_cmp.config(state=NORMAL)
            else:
                child_cmp.config(state=DISABLED)

    def appli_selection(self, event):
        if self.applis.get() != '':
            appli_id = list(self.applis[VALUES]).index(self.applis.get())
            luct_glo = LucteriosGlobal()
            current_inst_names = luct_glo.listing()
            appli_root_name = self.mod_applis[appli_id][0].split('.')[-1]
            default_name_idx = 1
            while appli_root_name + six.text_type(default_name_idx) in current_inst_names:
                default_name_idx += 1
            self.name.delete(0, END)
            self.name.insert(
                0, appli_root_name + six.text_type(default_name_idx))
            mod_depended = self.mod_applis[appli_id][2]
            self.modules.select_clear(0, self.modules.size())
            for mod_idx in range(len(self.module_data)):
                current_mod = self.module_data[mod_idx]
                if current_mod in mod_depended:
                    self.modules.selection_set(mod_idx)

    def mode_selection(self, event):
        visible = list(self.mode[VALUES]).index(self.mode.get()) != 2
        for child_cmp in self.frm_general.winfo_children()[-2:]:
            if visible:
                child_cmp.config(state=NORMAL)
            else:
                child_cmp.config(state=DISABLED)

    def apply(self):
        from lucterios.framework.settings import DEFAULT_LANGUAGES, get_locale_lang
        if self.name.get() == '':
            showerror(ugettext("Instance editor"), ugettext("Name empty!"))
            return
        if self.applis.get() == '':
            showerror(ugettext("Instance editor"), ugettext("No application!"))
            return
        db_param = "%s:name=%s,user=%s,password=%s" % (
            self.typedb.get(), self.namedb.get(), self.userdb.get(), self.pwddb.get())
        security = "MODE=%s" % list(
            self.mode[VALUES]).index(self.mode.get())
        if self.password.get() != '':
            security += ",PASSWORD=%s" % self.password.get()
        module_list = [
            self.module_data[int(item)] for item in self.modules.curselection()]
        appli_id = list(self.applis[VALUES]).index(self.applis.get())
        current_lang = get_locale_lang()
        for lang in DEFAULT_LANGUAGES:
            if lang[1] == self.language.get():
                current_lang = lang[0]
        self.result = (self.name.get(), self.mod_applis[appli_id][
                       0], ",".join(module_list), security, db_param, current_lang)
        self.destroy()

    def _load_current_data(self, instance_name):
        from lucterios.framework.settings import DEFAULT_LANGUAGES, get_locale_lang
        lct_inst = LucteriosInstance(instance_name)
        lct_inst.read()
        self.name.delete(0, END)
        self.name.insert(0, lct_inst.name)
        self.name.config(state=DISABLED)
        applis_id = 0
        for appli_iter in range(len(self.mod_applis)):
            if self.mod_applis[appli_iter][0] == lct_inst.appli_name:
                applis_id = appli_iter
                break
        self.applis.current(applis_id)
        if lct_inst.extra['']['mode'] is not None:
            self.mode.current(lct_inst.extra['']['mode'][0])
        else:
            self.mode.current(2)
        self.mode_selection(None)
        typedb_index = 0
        for typedb_idx in range(len(self.typedb[VALUES])):
            if self.typedb[VALUES][typedb_idx].lower() == lct_inst.database[0].lower():
                typedb_index = typedb_idx
                break
        self.typedb.current(typedb_index)
        self.typedb.config(state=DISABLED)
        self.typedb_selection(None)
        self.namedb.delete(0, END)
        if 'name' in lct_inst.database[1].keys():
            self.namedb.insert(0, lct_inst.database[1]['name'])
        self.userdb.delete(0, END)
        if 'user' in lct_inst.database[1].keys():
            self.userdb.insert(0, lct_inst.database[1]['user'])
        self.pwddb.delete(0, END)
        if 'password' in lct_inst.database[1].keys():
            self.pwddb.insert(0, lct_inst.database[1]['password'])
        self.modules.select_clear(0, self.modules.size())
        for mod_idx in range(len(self.module_data)):
            current_mod = self.module_data[mod_idx]
            if current_mod in lct_inst.modules:
                self.modules.select_set(mod_idx)
        current_lang = get_locale_lang()
        if 'LANGUAGE_CODE' in lct_inst.extra.keys():
            current_lang = lct_inst.extra['LANGUAGE_CODE']
        for lang in DEFAULT_LANGUAGES:
            if lang[0] == current_lang:
                self.language.current(self.language[VALUES].index(lang[1]))

    def execute(self, instance_name=None):
        from lucterios.framework.settings import DEFAULT_LANGUAGES, get_locale_lang
        self.mode[VALUES] = [ugettext(
            "CORE-connectmode.0"), ugettext("CORE-connectmode.1"), ugettext("CORE-connectmode.2")]
        self.language[VALUES] = [lang[1] for lang in DEFAULT_LANGUAGES]
        self.typedb[VALUES] = ["SQLite", "MySQL", "PostgreSQL"]
        lct_glob = LucteriosGlobal()
        _, self.mod_applis, mod_modules = lct_glob.installed()
        self.mod_applis.sort(key=lambda item: get_module_title(item[0]))
        self.modules.delete(0, END)
        self.module_data = []
        module_list = []
        for mod_module_item in mod_modules:
            module_list.append(
                (get_module_title(mod_module_item[0]), mod_module_item[0]))
        module_list.sort(key=lambda module: module[0])
        for module_title, module_name in module_list:
            self.modules.insert(END, module_title)
            self.module_data.append(module_name)
        appli_list = []
        for mod_appli_item in self.mod_applis:
            appli_list.append(get_module_title(mod_appli_item[0]))
        self.applis[VALUES] = appli_list
        if instance_name is not None:
            self._load_current_data(instance_name)
        else:
            self.typedb.current(0)
            self.mode.current(2)
            if len(appli_list) > 0:
                self.applis.current(0)
            self.appli_selection(None)
            self.mode_selection(None)
            self.typedb_selection(None)
            for lang in DEFAULT_LANGUAGES:
                if lang[0] == get_locale_lang():
                    self.language.current(self.language[VALUES].index(lang[1]))
        center(self)
Beispiel #43
0
class LucteriosMainForm(Tk):

    def __init__(self):
        Tk.__init__(self)
        try:
            img = Image("photo", file=join(
                dirname(import_module('lucterios.install').__file__), "lucterios.png"))
            self.tk.call('wm', 'iconphoto', self._w, img)
        except:
            pass
        self.has_checked = False
        self.title(ugettext("Lucterios installer"))
        self.minsize(475, 260)
        self.grid_columnconfigure(0, weight=1)
        self.grid_rowconfigure(0, weight=1)
        self.running_instance = {}
        self.resizable(True, True)
        self.protocol("WM_DELETE_WINDOW", self.on_closing)

        self.ntbk = ttk.Notebook(self)
        self.ntbk.grid(row=0, column=0, columnspan=1, sticky=(N, S, E, W))

        self.create_instance_panel()
        self.create_module_panel()

        stl = ttk.Style()
        stl.theme_use("default")
        stl.configure("TProgressbar", thickness=5)
        self.progress = ttk.Progressbar(
            self, style="TProgressbar", orient='horizontal', mode='indeterminate')
        self.progress.grid(row=1, column=0, sticky=(E, W))

        self.btnframe = Frame(self, bd=1)
        self.btnframe.grid(row=2, column=0, columnspan=1)
        Button(self.btnframe, text=ugettext("Refresh"), width=20, command=self.refresh).grid(
            row=0, column=0, padx=3, pady=3, sticky=(N, S))
        self.btnupgrade = Button(
            self.btnframe, text=ugettext("Search upgrade"), width=20, command=self.upgrade)
        self.btnupgrade.config(state=DISABLED)
        self.btnupgrade.grid(row=0, column=1, padx=3, pady=3, sticky=(N, S))
        Button(self.btnframe, text=ugettext("Close"), width=20, command=self.on_closing).grid(
            row=0, column=2, padx=3, pady=3, sticky=(N, S))

    def on_closing(self):
        all_stop = True
        instance_names = list(self.running_instance.keys())
        for old_item in instance_names:
            if (self.running_instance[old_item] is not None) and self.running_instance[old_item].is_running():
                all_stop = False
        if all_stop or askokcancel(None, ugettext("An instance is always running.\nDo you want to close?")):
            self.destroy()
        else:
            self.refresh()

    def destroy(self):
        instance_names = list(self.running_instance.keys())
        for old_item in instance_names:
            if self.running_instance[old_item] is not None:
                self.running_instance[old_item].stop()
                del self.running_instance[old_item]
        Tk.destroy(self)

    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 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'))

    def do_progress(self, progressing):
        if not progressing:
            self.progress.stop()
            self.progress.grid_remove()
        else:
            self.progress.start(25)
            self.progress.grid(row=1, column=0, sticky=(E, W))

    def enabled(self, is_enabled, widget=None):
        if widget is None:
            widget = self
            self.do_progress(not is_enabled)
        if is_enabled:
            widget.config(cursor="")
        else:

            widget.config(cursor="watch")
        if isinstance(widget, Button) and (widget != self.btnupgrade):
            if is_enabled and (not hasattr(widget, 'disabled') or not widget.disabled):
                widget.config(state=NORMAL)
            else:
                widget.config(state=DISABLED)
        else:
            for child_cmp in widget.winfo_children():
                self.enabled(is_enabled, child_cmp)

    @ThreadRun
    def refresh(self, instance_name=None):
        if instance_name is None:
            instance_name = self.get_selected_instance_name()
        self.instance_txt.delete("1.0", END)
        self._refresh_instance_list()
        self.set_select_instance_name(instance_name)
        if not self.has_checked:
            self._refresh_modules()
            if self.instance_list.size() == 0:
                sleep(.3)
                self._refresh_modules()
                sleep(.3)
                self.after_idle(self.add_inst)

    def _refresh_modules(self):
        self.btnupgrade.config(state=DISABLED)
        self.module_txt.config(state=NORMAL)
        self.module_txt.delete("1.0", END)
        lct_glob = LucteriosGlobal()
        mod_lucterios, mod_applis, mod_modules = lct_glob.installed()
        self.module_txt.insert(
            END, ugettext("Lucterios core\t\t%s\n") % mod_lucterios[1])
        self.module_txt.insert(END, '\n')
        self.module_txt.insert(END, ugettext("Application\n"))
        for appli_item in mod_applis:
            self.module_txt.insert(
                END, "\t%s\t%s\n" % (appli_item[0].ljust(30), appli_item[1]))
        self.module_txt.insert(END, ugettext("Modules\n"))
        for module_item in mod_modules:
            self.module_txt.insert(
                END, "\t%s\t%s\n" % (module_item[0].ljust(30), module_item[1]))
        extra_urls = lct_glob.get_extra_urls()
        if len(extra_urls) > 0:
            self.module_txt.insert(END, "\n")
            self.module_txt.insert(END, ugettext("Pypi servers\n"))
            for extra_url in extra_urls:
                self.module_txt.insert(END, "\t%s\n" % extra_url)
        self.module_txt.config(state=DISABLED)
        self.has_checked = True

        self.after(1000, lambda: Thread(target=self.check).start())

    def _refresh_instance_list(self):
        self.instance_list.delete(0, END)
        luct_glo = LucteriosGlobal()
        instance_list = luct_glo.listing()
        for item in instance_list:
            self.instance_list.insert(END, item)
            if item not in self.running_instance.keys():
                self.running_instance[item] = None

        instance_names = list(self.running_instance.keys())
        for old_item in instance_names:
            if old_item not in instance_list:
                if self.running_instance[old_item] is not None:
                    self.running_instance[old_item].stop()
                del self.running_instance[old_item]

    def set_select_instance_name(self, instance_name):
        cur_sel = 0
        for sel_iter in range(self.instance_list.size()):
            if self.instance_list.get(sel_iter) == instance_name:
                cur_sel = sel_iter
                break
        self.instance_list.selection_set(cur_sel)
        self.select_instance(None)

    def get_selected_instance_name(self):
        if len(self.instance_list.curselection()) > 0:
            return self.instance_list.get(int(self.instance_list.curselection()[0]))
        else:
            return ""

    def set_ugrade_state(self, must_upgrade):
        if must_upgrade:
            self.btnupgrade.config(state=NORMAL)
            self.btnupgrade["text"] = ugettext("Upgrade needs")
        else:
            self.btnupgrade["text"] = ugettext("No upgrade")
            self.btnupgrade.config(state=DISABLED)

    def check(self):
        must_upgrade = False
        try:
            lct_glob = LucteriosGlobal()
            _, must_upgrade = lct_glob.check()
        finally:
            self.after(300, self.set_ugrade_state, must_upgrade)

    @ThreadRun
    def upgrade(self):
        self.btnupgrade.config(state=DISABLED)
        self.instance_list.config(state=DISABLED)
        try:
            from logging import getLogger
            admin_path = import_module(
                "lucterios.install.lucterios_admin").__file__
            proc = Popen(
                [sys.executable, admin_path, "update"], stderr=STDOUT, stdout=PIPE)
            value = proc.communicate()[0]
            try:
                value = value.decode('ascii')
            except:
                pass
            six.print_(value)
            if proc.returncode != 0:
                getLogger("lucterios.admin").error(value)
            else:
                getLogger("lucterios.admin").info(value)
            showinfo(ugettext("Lucterios installer"), ugettext(
                "The application must restart"))
            python = sys.executable
            os.execl(python, python, *sys.argv)
        finally:
            self._refresh_modules()
            self.btnupgrade.config(state=NORMAL)
            self.instance_list.config(state=NORMAL)

    @ThreadRun
    def select_instance(self, evt):

        if self.instance_list['state'] == NORMAL:
            self.instance_list.config(state=DISABLED)
            try:
                instance_name = self.get_selected_instance_name()
                self.instance_txt.configure(state=NORMAL)
                self.instance_txt.delete("1.0", END)
                if instance_name != '':
                    if instance_name not in self.running_instance.keys():
                        self.running_instance[instance_name] = None
                    inst = LucteriosInstance(instance_name)
                    inst.read()
                    self.instance_txt.insert(END, "\t\t\t%s\n\n" % inst.name)
                    self.instance_txt.insert(
                        END, ugettext("Database\t\t%s\n") % inst.get_database_txt())
                    self.instance_txt.insert(
                        END, ugettext("Appli\t\t%s\n") % inst.get_appli_txt())
                    self.instance_txt.insert(
                        END, ugettext("Modules\t\t%s\n") % inst.get_module_txt())
                    self.instance_txt.insert(
                        END, ugettext("Extra\t\t%s\n") % inst.get_extra_txt())
                    self.instance_txt.insert(END, '\n')
                    if self.running_instance[instance_name] is not None and self.running_instance[instance_name].is_running():
                        self.instance_txt.insert(END, ugettext(
                            "=> Running in http://%(ip)s:%(port)d\n") % {'ip': self.running_instance[instance_name].lan_ip, 'port': self.running_instance[instance_name].port})
                        self.btninstframe.winfo_children()[0]["text"] = ugettext(
                            "Stop")
                    else:
                        self.running_instance[instance_name] = None
                        self.instance_txt.insert(END, ugettext("=> Stopped\n"))
                        self.btninstframe.winfo_children()[0]["text"] = ugettext(
                            "Launch")
                else:
                    self.btninstframe.winfo_children()[0]["text"] = ugettext(
                        "Launch")
                self.btninstframe.winfo_children()[0].disabled = (
                    instance_name == '')
                self.btninstframe.winfo_children()[1].disabled = (
                    instance_name == '')
                self.btninstframe.winfo_children()[2].disabled = (
                    instance_name == '')
                self.btninstframe.winfo_children()[3].disabled = (
                    instance_name == '')
                self.btninstframe.winfo_children()[4].disabled = (
                    instance_name == '')
                self.instance_txt.configure(state=DISABLED)
            finally:
                setup_from_none()
                self.instance_list.config(state=NORMAL)

    @ThreadRun
    def add_modif_inst_result(self, result, to_create):
        inst = LucteriosInstance(result[0])
        inst.set_extra("LANGUAGE_CODE='%s'" % result[5])
        inst.set_appli(result[1])
        inst.set_module(result[2])
        inst.set_database(result[4])
        if to_create:
            inst.add()
        else:
            inst.modif()
        inst = LucteriosInstance(result[0])
        inst.set_extra(result[3])
        inst.security()
        self.refresh(result[0])

    def add_inst(self):
        self.enabled(False)
        try:
            self.do_progress(False)
            ist_edt = InstanceEditor()
            ist_edt.execute()
            ist_edt.transient(self)
            self.wait_window(ist_edt)
        finally:
            self.enabled(True)
        if ist_edt.result is not None:
            self.add_modif_inst_result(ist_edt.result, True)

    def modify_inst(self):
        self.enabled(False)
        try:
            self.do_progress(False)
            ist_edt = InstanceEditor()
            ist_edt.execute(self.get_selected_instance_name())
            ist_edt.transient(self)
            self.wait_window(ist_edt)
        finally:
            self.enabled(True)
        if ist_edt.result is not None:
            self.add_modif_inst_result(ist_edt.result, False)

    @ThreadRun
    def delete_inst_name(self, instance_name):
        inst = LucteriosInstance(instance_name)
        inst.delete()
        self.refresh()

    def delete_inst(self):
        setup_from_none()
        instance_name = self.get_selected_instance_name()
        if askokcancel(None, ugettext("Do you want to delete '%s'?") % instance_name):
            self.delete_inst_name(instance_name)
        else:
            self.refresh()

    @ThreadRun
    def open_inst(self):
        instance_name = self.get_selected_instance_name()
        if instance_name != '':
            try:
                if instance_name not in self.running_instance.keys():
                    self.running_instance[instance_name] = None
                if self.running_instance[instance_name] is None:
                    port = FIRST_HTTP_PORT
                    for inst_obj in self.running_instance.values():
                        if (inst_obj is not None) and (inst_obj.port >= port):
                            port = inst_obj.port + 1
                    self.running_instance[instance_name] = RunServer(
                        instance_name, port)
                    self.running_instance[instance_name].start()
                else:
                    self.running_instance[instance_name].stop()
                    self.running_instance[instance_name] = None
            finally:
                self.set_select_instance_name(instance_name)

    @ThreadRun
    def save_instance(self, instance_name, file_name):
        inst = LucteriosInstance(instance_name)
        inst.filename = file_name
        if inst.archive():
            showinfo(ugettext("Lucterios installer"), ugettext(
                "Instance saved to %s") % file_name)
        else:
            showerror(
                ugettext("Lucterios installer"), ugettext("Instance not saved!"))
        self.refresh(instance_name)

    def save_inst(self):
        instance_name = self.get_selected_instance_name()
        if instance_name != '':
            file_name = asksaveasfilename(
                parent=self, filetypes=[('lbk', '.lbk'), ('*', '.*')])
            if file_name != '':
                self.save_instance(instance_name, file_name)

    @ThreadRun
    def restore_instance(self, instance_name, file_name):
        if file_name[-4:] == '.bkf':
            rest_inst = MigrateFromV1(instance_name, withlog=True)
        else:
            rest_inst = LucteriosInstance(instance_name)
        rest_inst.filename = file_name
        if rest_inst.restore():
            showinfo(ugettext("Lucterios installer"), ugettext(
                "Instance restore from %s") % file_name)
        else:
            showerror(
                ugettext("Lucterios installer"), ugettext("Instance not restored!"))
        self.refresh(instance_name)

    def restore_inst(self):
        instance_name = self.get_selected_instance_name()
        if instance_name != '':
            file_name = askopenfilename(
                parent=self, filetypes=[('lbk', '.lbk'), ('bkf', '.bkf'), ('*', '.*')])
            if file_name != '':
                self.restore_instance(instance_name, file_name)

    def execute(self):
        self.refresh()
        center(self, (700, 300))
        self.mainloop()