Exemplo n.º 1
0
 def test_showtip(self):
     tooltip = Hovertip(self.button, 'ToolTip text')
     self.addCleanup(tooltip.hidetip)
     self.assertFalse(tooltip.tipwindow
                      and tooltip.tipwindow.winfo_viewable())
     tooltip.showtip()
     self.assertTrue(tooltip.tipwindow
                     and tooltip.tipwindow.winfo_viewable())
Exemplo n.º 2
0
 def test_showtip_on_mouse_enter_no_delay(self):
     tooltip = Hovertip(self.button, 'ToolTip text', hover_delay=None)
     self.addCleanup(tooltip.hidetip)
     tooltip.showtip = add_call_counting(tooltip.showtip)
     root.update()
     self.assertFalse(self.is_tipwindow_shown(tooltip))
     self.button.event_generate('<Enter>', x=0, y=0)
     root.update()
     self.assertTrue(self.is_tipwindow_shown(tooltip))
     self.assertGreater(len(tooltip.showtip.call_args_list), 0)
class ChooseFileButton(ButtonWithLabel):
    def __init__(self, parent, button_text):
        super().__init__(parent, button_text)
        self.label_text.set('No file specified.')
        self.hover_tip = Hovertip(self.label, text=self.label_text.get())

    def button_pressed(self):
        file = askopenfile(mode='r', filetypes=FILE_EXTENSIONS)
        if not (file is None):
            self.path = os.path.normpath(file.name)
            self.label_text.set(self.path)
            self.hover_tip.__setattr__('text', self.label_text.get())
class ChooseDirButton(ButtonWithLabel):
    def __init__(self, parent, button_text):
        super().__init__(parent, button_text)
        self.label_text.set('No folder specified.')
        self.hover_tip = Hovertip(self.label, text=self.label_text.get())

    def button_pressed(self):
        directory = askdirectory()
        if not (directory is None):
            self.path = os.path.normpath(directory)
            self.label_text.set(self.path)
            self.hover_tip.__setattr__('text', self.label_text.get())
Exemplo n.º 5
0
 def test_hidetip_on_mouse_leave(self):
     tooltip = Hovertip(self.button, 'ToolTip text', hover_delay=None)
     self.addCleanup(tooltip.hidetip)
     tooltip.showtip = add_call_counting(tooltip.showtip)
     root_update()
     self.button.event_generate('<Enter>', x=0, y=0)
     root_update()
     self.button.event_generate('<Leave>', x=0, y=0)
     root_update()
     self.assertFalse(tooltip.tipwindow
                      and tooltip.tipwindow.winfo_viewable())
     self.assertGreater(len(tooltip.showtip.call_args_list), 0)
Exemplo n.º 6
0
 def test_dont_show_on_mouse_leave_before_delay(self):
     tooltip = Hovertip(self.button, 'ToolTip text', hover_delay=50)
     self.addCleanup(tooltip.hidetip)
     tooltip.showtip = add_call_counting(tooltip.showtip)
     root_update()
     self.button.event_generate('<Enter>', x=0, y=0)
     root_update()
     self.button.event_generate('<Leave>', x=0, y=0)
     root_update()
     time.sleep(0.1)
     root_update()
     self.assertFalse(tooltip.tipwindow
                      and tooltip.tipwindow.winfo_viewable())
     self.assertEqual(tooltip.showtip.call_args_list, [])
Exemplo n.º 7
0
    def __init__(self, s, tags, numoflines, squeezer):
        self.s = s
        self.tags = tags
        self.numoflines = numoflines
        self.squeezer = squeezer
        self.editwin = editwin = squeezer.editwin
        self.text = text = editwin.text

        # the base Text widget of the PyShell object, used to change text
        # before the iomark
        self.base_text = editwin.per.bottom

        button_text = "Squeezed text (%d lines)." % self.numoflines
        tk.Button.__init__(self,
                           text,
                           text=button_text,
                           background="#FFFFC0",
                           activebackground="#FFFFE0")

        button_tooltip_text = (
            "Double-click to expand, right-click for more options.")
        Hovertip(self, button_tooltip_text, hover_delay=80)

        self.bind("<Double-Button-1>", self.expand)
        if macosx.isAquaTk():
            # AquaTk defines <2> as the right button, not <3>.
            self.bind("<Button-2>", self.context_menu_event)
        else:
            self.bind("<Button-3>", self.context_menu_event)
        self.selection_handle(
            lambda offset, length: s[int(offset):int(offset) + int(length)])

        self.is_dangerous = None
        self.after_idle(self.set_is_dangerous)
Exemplo n.º 8
0
    def __init__(self, s, tags, numoflines, squeezer):
        self.s = s
        self.tags = tags
        self.numoflines = numoflines
        self.squeezer = squeezer
        self.editwin = editwin = squeezer.editwin
        self.text = text = editwin.text
        # The base Text widget is needed to change text before iomark.
        self.base_text = editwin.per.bottom

        line_plurality = "lines" if numoflines != 1 else "line"
        button_text = f"Squeezed text ({numoflines} {line_plurality})."
        tk.Button.__init__(self,
                           text,
                           text=button_text,
                           background="#FFFFC0",
                           activebackground="#FFFFE0")

        button_tooltip_text = (
            "Double-click to expand, right-click for more options.")
        Hovertip(self, button_tooltip_text, hover_delay=80)

        self.bind("<Double-Button-1>", self.expand)
        if macosx.isAquaTk():
            # AquaTk defines <2> as the right button, not <3>.
            self.bind("<Button-2>", self.context_menu_event)
        else:
            self.bind("<Button-3>", self.context_menu_event)
        self.selection_handle(  # X windows only.
            lambda offset, length: s[int(offset):int(offset) + int(length)])

        self.is_dangerous = None
        self.after_idle(self.set_is_dangerous)
Exemplo n.º 9
0
 def make_label(self, parent, name, row=0, sticky='w', tooltip_text=''):
     """Make the human-friendly label for a form section."""
     name = name.capitalize().replace('_', ' ') + ':'
     label = ttk.Label(parent, text=name)
     label.grid(row=row, column=0, sticky=sticky)
     if len(tooltip_text) > 0:
         Hovertip(label, tooltip_text, hover_delay=1000)  # delay in ms
Exemplo n.º 10
0
    def __init__(self, parent, *args, **kwargs):
        ttk.Frame.__init__(self, parent, *args, **kwargs)
        self.parent = parent
        self.columnconfigure(1, weight=1)

        self.widget_button_open = ttk.Button(
            self,
            text="Open",
            command=lambda: open_file(self.parent),
            style="Toolbutton")
        self.widget_button_open.grid(row=0, column=0)
        Hovertip(self.widget_button_open, self.widget_button_open["text"])

        self.widget_button_exit = ttk.Button(self,
                                             text="Exit",
                                             command=self.parent.exit_program,
                                             style="Toolbutton")
        self.widget_button_exit.grid(row=0, column=1, sticky="e")
        Hovertip(self.widget_button_exit, self.widget_button_exit["text"])
Exemplo n.º 11
0
def create_tool_tip(widget, text, delay=500):
    tooltip = Hovertip(widget, " " + text + " ", delay)

    def enter(event):
        tooltip.showtip()

    def leave(event):
        tooltip.hidetip()

    widget.bind('<Enter>', enter)
    widget.bind('<Leave>', leave)
Exemplo n.º 12
0
    def test_hover_with_delay(self):
        # Run multiple tests requiring an actual delay simultaneously.

        # Test #1: A hover tip with a non-zero delay appears after the delay.
        tooltip1 = Hovertip(self.button, 'ToolTip text', hover_delay=100)
        self.addCleanup(tooltip1.hidetip)
        tooltip1.showtip = add_call_counting(tooltip1.showtip)
        root.update()
        self.assertFalse(self.is_tipwindow_shown(tooltip1))
        self.button.event_generate('<Enter>', x=0, y=0)
        root.update()
        self.assertFalse(self.is_tipwindow_shown(tooltip1))

        # Test #2: A hover tip with a non-zero delay doesn't appear when
        # the mouse stops hovering over the base widget before the delay
        # expires.
        tooltip2 = Hovertip(self.button, 'ToolTip text', hover_delay=100)
        self.addCleanup(tooltip2.hidetip)
        tooltip2.showtip = add_call_counting(tooltip2.showtip)
        root.update()
        self.button.event_generate('<Enter>', x=0, y=0)
        root.update()
        self.button.event_generate('<Leave>', x=0, y=0)
        root.update()

        time.sleep(0.15)
        root.update()

        # Test #1 assertions.
        self.assertTrue(self.is_tipwindow_shown(tooltip1))
        self.assertGreater(len(tooltip1.showtip.call_args_list), 0)

        # Test #2 assertions.
        self.assertFalse(self.is_tipwindow_shown(tooltip2))
        self.assertEqual(tooltip2.showtip.call_args_list, [])
Exemplo n.º 13
0
 def test_showtip_twice(self):
     tooltip = Hovertip(self.button, 'ToolTip text')
     self.addCleanup(tooltip.hidetip)
     self.assertFalse(self.is_tipwindow_shown(tooltip))
     tooltip.showtip()
     self.assertTrue(self.is_tipwindow_shown(tooltip))
     orig_tipwindow = tooltip.tipwindow
     tooltip.showtip()
     self.assertTrue(self.is_tipwindow_shown(tooltip))
     self.assertIs(tooltip.tipwindow, orig_tipwindow)
Exemplo n.º 14
0
    def navigation_widgets(self):
        global home_dic

        # Home button
        self.home_icon = PhotoImage(file=home_dic + '\\assets\\images\\Menu_home.png')
        self.home_btn = tk.Button(self.frame_navigation, image=self.home_icon, bg='red', command=self.load_widgets)
        Hovertip(self.home_btn, "Home/Load file", hover_delay=300)
        self.home_btn.grid(row=0, column=0, sticky=tk.E, padx=(5, 0), pady=(3, 0))

        # Hearts button
        self.heart_icon = PhotoImage(file=home_dic + '\\assets\\images\\Menu_hearts.png')
        self.heart_btn = tk.Button(self.frame_navigation, image=self.heart_icon, bg='red', command=partial(self.load_widgets, "hearts"))
        Hovertip(self.heart_btn, "Heart selection", hover_delay=300)
        self.heart_btn.grid(row=0, column=1, sticky=tk.E, padx=(5, 0), pady=(3, 0))
        self.heart_btn['state'] = 'disabled'

        # Prayers button
        self.prayer_icon = PhotoImage(file=home_dic + '\\assets\\images\\Menu_prayers.png')
        self.prayer_btn = tk.Button(self.frame_navigation, image=self.prayer_icon, bg='red', command=partial(self.load_widgets, "prayers"))
        Hovertip(self.prayer_btn, "Prayer selection", hover_delay=300)
        self.prayer_btn.grid(row=0, column=2, sticky=tk.E, padx=(5, 0), pady=(3, 0))
        self.prayer_btn['state'] = 'disabled'

        # Relics button
        self.relic_icon = PhotoImage(file=home_dic + '\\assets\\images\\Menu_relics.png')
        self.relic_btn = tk.Button(self.frame_navigation, image=self.relic_icon, bg='red', command=partial(self.load_widgets, "relics"))
        Hovertip(self.relic_btn, "Relic selection", hover_delay=300)
        self.relic_btn.grid(row=0, column=3, sticky=tk.E, padx=(5, 0), pady=(3, 0))
        self.relic_btn['state'] = 'disabled'

        # Beads button
        self.bead_icon = PhotoImage(file=home_dic + '\\assets\\images\\Menu_beads.png')
        self.bead_btn = tk.Button(self.frame_navigation, image=self.bead_icon, bg='red', command=partial(self.load_widgets, "beads"))
        Hovertip(self.bead_btn, "Bead selection", hover_delay=300)
        self.bead_btn.grid(row=0, column=4, sticky=tk.E, padx=(5, 0), pady=(3, 0))
        self.bead_btn['state'] = 'disabled'

        # Stats button
        self.stats_icon = PhotoImage(file=home_dic + '\\assets\\images\\Menu_stats.png')
        self.stats_btn = tk.Button(self.frame_navigation, image=self.stats_icon, bg='red', command=partial(self.load_widgets, "stats"))
        Hovertip(self.stats_btn, "Stats display", hover_delay=300)
        self.stats_btn.grid(row=0, column=5, sticky=tk.E, padx=(5, 0), pady=(3, 0))
        self.stats_btn['state'] = 'disabled'

        # Abilities button
        self.abilities_icon = PhotoImage(file=home_dic + '\\assets\\images\\Menu_abilities.png')
        self.abilities_btn = tk.Button(self.frame_navigation, image=self.abilities_icon, bg='red', command=partial(self.load_widgets, "abilities"))
        Hovertip(self.abilities_btn, "Abilities selection", hover_delay=300)
        self.abilities_btn.grid(row=0, column=6, sticky=tk.E, padx=(5, 0), pady=(3, 0))
        self.abilities_btn['state'] = 'disabled'
Exemplo n.º 15
0
 def seleccionar_click2(self, event):
     self.clean()
     self.bgpedido["state"] = "disable"
     self.bapedido["state"] = "normal"
     self.bepedido["state"] = "normal"
     self.selected = self.tree3.focus()
     self.values = self.tree3.item(self.selected, 'values')
     self.ci.insert(0, self.values[0])
     self.id_pro.insert(0, self.values[1])
     self.cant.insert(0, self.values[2])
     self.Id_operacion1 = self.values[1]
     self.cant_v1 = self.values[2]
     self.ci_pedido_v = self.values[0]
     self.ci.configure(state='disable')
     Hovertip(self.ci,
              text="No puede actualizar la CI de los pedidos ya ingresados",
              hover_delay=100)
Exemplo n.º 16
0
 def seleccionar1_click(self, event):
     self.clean1()
     self.b_guardar["state"] = "disable"
     self.b_actualizar["state"] = "normal"
     self.b_eliminar["state"] = "normal"
     self.selected = self.tree1.focus()
     self.values = self.tree1.item(self.selected, 'values')
     self.ci_cliente.insert(0, self.values[0])
     self.nombre.insert(0, self.values[1])
     self.apellido.insert(0, self.values[2])
     self.telefono.insert(0, self.values[3])
     self.direccion.insert(0, self.values[4])
     self.deuda.insert(0, self.values[5])
     self.ci_cliente.configure(state='disable')
     Hovertip(self.ci_cliente,
              text="No puede actualizar la cedula de un usuario existente",
              hover_delay=100)
Exemplo n.º 17
0
 def seleccionar_click(self, event):
     self.clean()
     self.b1["state"] = "disable"
     self.b2["state"] = "normal"
     self.b3["state"] = "normal"
     self.selected = self.tree.focus()
     self.values = self.tree.item(self.selected, 'values')
     self.id.insert(0, self.values[0])
     self.price_c.insert(0, self.values[1])
     self.price_v.insert(0, self.values[2])
     self.amount.insert(0, self.values[3])
     self.cant_v = self.values[3]
     self.Id_operacion = self.values[0]
     self.id.configure(state='disable')
     Hovertip(
         self.id,
         text="No puede actualizar el ID de los productos ya ingresados",
         hover_delay=100)
Exemplo n.º 18
0
img15 = Image.open(r'icons/bnb.png')
useImg15 = ImageTk.PhotoImage(img15)
img16 = Image.open(r'icons/bch.png')
useImg16 = ImageTk.PhotoImage(img16)
img17 = Image.open(r'icons/vet.png')
useImg17 = ImageTk.PhotoImage(img17)
img18 = Image.open(r'icons/neo.png')
useImg18 = ImageTk.PhotoImage(img18)
img19 = Image.open(r'icons/Calculator.png')
useImg19 = ImageTk.PhotoImage(img19)


# ***** Toolbar *****
toolbar = Frame(window, bg="#dedcdc")
insertB1 = Button(toolbar, image=useImg1, activebackground='#00ff00', command=btc_cpr)
Tip1 = Hovertip(insertB1, 'Bitcoin')
insertB1.pack(side=LEFT, padx=2, pady=2)
insertB2 = Button(toolbar, image=useImg2, activebackground='#00ff00', command=eth_cpr)
Tip2 = Hovertip(insertB2, 'Ethereum')
insertB2.pack(side=LEFT, padx=2, pady=2)
insertB3 = Button(toolbar, image=useImg3, activebackground='#00ff00', command=ada_cpr)
Tip3 = Hovertip(insertB3, 'Cardano')
insertB3.pack(side=LEFT, padx=2, pady=2)
insertB4 = Button(toolbar, image=useImg4, activebackground='#00ff00', command=xlm_cpr)
Tip4 = Hovertip(insertB4, 'Stellar Lumens')
insertB4.pack(side=LEFT, padx=2, pady=2)
insertB5 = Button(toolbar, image=useImg5, activebackground='#00ff00', command=dgb_cpr)
Tip5 = Hovertip(insertB5, 'DigiByte')
insertB5.pack(side=LEFT, padx=2, pady=2)
insertB6 = Button(toolbar, image=useImg6, activebackground='#00ff00', command=trx_cpr)
Tip6 = Hovertip(insertB6, 'Tron')
Exemplo n.º 19
0
    def __init__(self):
        print("Init gui...")
        self.settings = None
        self.woofer = None
        self.twitch = None
        self.chatbot = None
        self.overlay = None

        # Root
        self.app = Tk()
        self.app.geometry("800x450")
        self.app.resizable(width=False, height=False)
        self.app.title("Wooferbot")
        self.app.iconbitmap("wooferbot.ico")

        # ---------------------------
        # Tabs
        # ---------------------------
        self.app.grid_rowconfigure(0, weight=1)
        self.app.grid_columnconfigure(0, weight=1)
        self.tab_control = ttk.Notebook(self.app)
        self.tab_control.grid(row=0, column=0, columnspan=4, sticky="NSEW")
        tab1 = Frame(self.tab_control)

        self.tab_control.add(tab1, text="Log")

        # ---------------------------
        # Status bar
        # ---------------------------
        self.statusbar_frame = Frame(self.app)
        self.statusbar_frame.grid(row=1, column=0, sticky=NSEW)
        self.statusbar_frame.grid_columnconfigure(3, weight=1)

        self.statusbar_twitch = Label(
            self.statusbar_frame,
            text="Twitch",
            bd=1,
            fg="GRAY",
            width=10,
            relief=SUNKEN,
            anchor=W,
            padx=1,
            pady=1,
        )
        self.statusbar_twitch.tooltip = Hovertip(self.statusbar_twitch,
                                                 "Twitch disabled",
                                                 hover_delay=100)
        self.statusbar_twitch.grid(row=0, column=0, sticky=W)
        self.statusbar_chatbot = Label(
            self.statusbar_frame,
            text="Chatbot",
            bd=1,
            fg="GRAY",
            width=10,
            relief=SUNKEN,
            anchor=W,
            padx=1,
            pady=1,
        )
        self.statusbar_chatbot.tooltip = Hovertip(self.statusbar_chatbot,
                                                  "Chatbot disabled",
                                                  hover_delay=100)
        self.statusbar_chatbot.grid(row=0, column=1, sticky=W)
        self.statusbar_overlay = Label(
            self.statusbar_frame,
            text="Overlay",
            bd=1,
            fg="GRAY",
            width=10,
            relief=SUNKEN,
            anchor=W,
            padx=1,
            pady=1,
        )
        self.statusbar_overlay.tooltip = Hovertip(self.statusbar_overlay,
                                                  "Overlay disabled",
                                                  hover_delay=100)
        self.statusbar_overlay.grid(row=0, column=2, sticky=W)
        Label(self.statusbar_frame,
              bd=1,
              relief=SUNKEN,
              anchor=W,
              padx=1,
              pady=1).grid(row=0, column=3, sticky=EW)

        # ---------------------------
        # [Tab] Log
        # ---------------------------
        tab1.grid_columnconfigure([0], weight=1)
        tab1.grid_rowconfigure(0, weight=1)

        # [Tab] Log - Log Frame
        frame_log = LabelFrame(tab1, text="Log", padx=5, pady=5)
        frame_log.grid(row=0, column=0, padx=2, pady=2, sticky=["NSWE"])
        frame_log.grid_rowconfigure(0, weight=1)
        frame_log.grid_columnconfigure(0, weight=1)

        mls = Scrollbar(frame_log, orient="vertical")
        mls.grid(row=0, column=1, sticky=["N", "S", "E"])
        self.message_log = Listbox(frame_log, yscrollcommand=mls.set)
        mls.configure(command=self.message_log.yview)
        self.message_log.grid(row=0, column=0, sticky=["NSWE"])

        # [Tab] Log - Control Frame
        self.frame_control = LabelFrame(tab1, text="Controls", padx=5, pady=5)
        self.frame_control.grid(row=0,
                                column=1,
                                padx=2,
                                pady=2,
                                sticky=["N", "S", "E"])

        def cmd_clear_notifications():
            self.woofer.queue.clear()

        def cmd_pause_notifications():
            self.woofer.queuePaused = True
            self.pause_notifications["text"] = "Resume notifications"
            self.pause_notifications["command"] = cmd_resume_notifications

        def cmd_resume_notifications():
            self.woofer.queuePaused = False
            self.pause_notifications["text"] = "Pause notifications"
            self.pause_notifications["command"] = cmd_pause_notifications

        def cmd_reconnect_twitch_accounts():
            if hasattr(self.twitch, "connected") and self.twitch.connected:
                self.twitch.disconnect()
            if hasattr(self.chatbot, "connected") and self.chatbot.connected:
                self.chatbot.disconnect()

        clear_notifications = Button(
            self.frame_control,
            text="Clear notifications",
            width=15,
            command=cmd_clear_notifications,
        )
        clear_notifications.tooltip = Hovertip(
            clear_notifications,
            "Clear all waiting notifications",
            hover_delay=100)
        clear_notifications.grid(row=0, column=0, sticky=E)
        self.pause_notifications = Button(
            self.frame_control,
            text="Pause notifications",
            width=15,
            command=cmd_pause_notifications,
        )
        self.pause_notifications.tooltip = Hovertip(self.pause_notifications,
                                                    "Pause notifications",
                                                    hover_delay=100)
        self.pause_notifications.grid(row=1, column=0, sticky=E)
        reconnect_twitch = Button(
            self.frame_control,
            text="Reconnect Twitch",
            width=15,
            command=cmd_reconnect_twitch_accounts,
        )
        reconnect_twitch.tooltip = Hovertip(
            reconnect_twitch,
            "Reconnect all connections to Twitch",
            hover_delay=100)
        reconnect_twitch.grid(row=2, column=0, sticky=E)

        self.app.update_idletasks()
        self.app.update()
 def __init__(self, parent, button_text):
     super().__init__(parent, button_text)
     self.label_text.set('No folder specified.')
     self.hover_tip = Hovertip(self.label, text=self.label_text.get())
Exemplo n.º 21
0
    def __init__(self, run_callback: Callable, close_callback: Callable):
        self._root = tk.Tk()
        self._root.wm_title("YouTube статистика")

        label = tk.Label(width=40)
        label["text"] = "Дата отсечки:"
        label.pack()

        self._date = DateEntry(master=self._root, width=38)
        self._date.pack()

        Hovertip(
            self._date,
            text=
            "Программа будет искать видео на каналах из списка channels.txt, которые вышли \n"
            "после указанной даты. На анализ видео из списка videos.txt этот параметр не влияет",
        )

        label = tk.Label(width=40)
        label["text"] = "Google API ключ:"
        label.pack()

        self._api = tk.StringVar()
        key_entry = tk.Entry(master=self._root,
                             textvariable=self._api,
                             width=40)
        key_entry.pack()
        self._api.set(Settings.api_key())
        Hovertip(key_entry, text="Ваш Google API Key для доступа к YouTube")

        self._bots_frame = tk.LabelFrame(self._root,
                                         text="Группы ботов",
                                         width=40)
        Hovertip(self._bots_frame,
                 "Какие категории ботов будут учитываться при анализе")

        self._bot_groups = dict()

        for bot_group in Settings.bot_list_links().keys():
            self._bot_groups[bot_group] = tk.IntVar(value=0)
            check = tk.Checkbutton(
                self._bots_frame,
                text=bot_group,
                width=38,
                variable=self._bot_groups[bot_group],
            )
            check.pack()

        self._bots_frame.pack(padx=5, pady=5)

        self._bot_list_inverted = tk.IntVar(value=0)
        inverter = tk.Checkbutton(text="Только из указанных списков",
                                  variable=self._bot_list_inverted)
        inverter.pack()
        Hovertip(
            inverter,
            "Если этот пункт выбран, в статистике будут учитываться только акаунты ботов из выбранных\n"
            "выше списков (групп). Если этот пункт не выбран, в статистике будут учитываться аккаунты\n"
            "всех пользователей, кроме тех, которые есть в выбранных списках",
        )

        self._video_stat = tk.IntVar(value=0)
        video_stat = tk.Checkbutton(text="Распределять по видео",
                                    variable=self._video_stat)
        video_stat.pack()
        Hovertip(
            video_stat,
            "Если этот пункт выбран, в статистике будет распределение комментариев по видеороликам, а не только "
            "по каналам",
        )

        self._start_btn = tk.Button(master=self._root,
                                    text="Начать",
                                    command=lambda: run_callback(self))
        self._start_btn.pack()

        self._root.protocol("WM_DELETE_WINDOW", close_callback)
Exemplo n.º 22
0
    def windpedido1(self):
        self.wind.iconify()
        self.windpedido = Toplevel()
        self.windpedido.resizable(width=0, height=0)
        self.windpedido.geometry("800x500")
        self.windpedido.iconbitmap('archivo.ico')

        self.l2 = Label(self.windpedido, text="Ingrese un pedido")
        self.l2.place(x=345, y=40)

        self.lci = Label(self.windpedido, text="CI: ")
        self.lci.place(x=356, y=65)
        self.ci = Entry(self.windpedido, width=30)
        self.ci.focus()
        self.ci.place(x=400, y=65)

        self.lid_pro = Label(self.windpedido, text="ID Producto: ")
        self.lid_pro.place(x=304, y=95)
        self.id_pro = Entry(self.windpedido, width=30)
        self.id_pro.place(x=400, y=95)

        self.lcant = Label(self.windpedido, text="Cantidad Producto: ")
        self.lcant.place(x=267, y=125)
        self.cant = Entry(self.windpedido, width=30)
        self.cant.place(x=400, y=125)

        self.bgpedido = ttk.Button(self.windpedido,
                                   text="Guardar Pedido",
                                   width=60,
                                   command=self.agregar_pedido)
        self.bgpedido.place(x=215, y=160)

        self.bepedido = ttk.Button(self.windpedido,
                                   text="Eliminar Pedido",
                                   width=60,
                                   command=self.editar_pedido_inventario)
        self.bepedido.place(x=400, y=450)
        self.bepedido['state'] = 'disable'

        self.bapedido = ttk.Button(self.windpedido,
                                   text="Actualizar Pedido",
                                   width=60,
                                   command=self.editar_pedido_inventario)
        self.bapedido.place(x=30, y=450)
        self.bapedido['state'] = 'disable'

        self.bpsearch = Button(self.windpedido,
                               width=35,
                               height=35,
                               command=self.buscar_pedido)
        self.bpsearch.config(image=self.img)
        self.bpsearch.place(x=15, y=15)
        Hovertip(self.bsearch, text="BUSCAR")

        self.img6 = PhotoImage(file='home.png')
        self.bprin_pedido = Button(self.windpedido,
                                   width=35,
                                   height=35,
                                   command=self.principal_pedido)
        self.bprin_pedido.config(image=self.img6)
        self.bprin_pedido.place(x=15, y=65)
        Hovertip(self.bprin_pedido, text="PANTALLA PRINCIPAL")

        self.tree3 = ttk.Treeview(self.windpedido)
        self.tree3['columns'] = ("CI", "ID_PRODUCTO", "CANTIDAD_PRODUCTO",
                                 "FECHA")
        self.tree3.place(x=0, y=200)
        self.tree3.bind("<Double-Button-1>", self.seleccionar_click2)
        self.tree3.column('#0', width=0, stretch=NO)
        self.tree3.column('#1', minwidth=200, anchor=CENTER)
        self.tree3.column('#2', minwidth=200, anchor=CENTER)
        self.tree3.column('#3', minwidth=200, anchor=CENTER)
        self.tree3.column('#4', minwidth=200, anchor=CENTER)
        self.tree3.heading('#1', text='CI CLIENTE', anchor=CENTER)
        self.tree3.heading('#2', text='ID PRODUCTO', anchor=CENTER)
        self.tree3.heading('#3', text='CANTIDAD PRODUCTO', anchor=CENTER)
        self.tree3.heading('#4', text='FECHA', anchor=CENTER)
        self.obt_pedidos()
Exemplo n.º 23
0
def show_streams_mediainfo_function(x):  # Stream Viewer
    global stream_win_text_area, exit_stream_window, stream_window
    video_input = pathlib.Path(x)  # "x" is passed through from main GUI

    # Defines the path to config.ini and opens it for reading/writing
    config_file = 'Runtime/config.ini'  # Creates (if it doesn't exist) and defines location of config.ini
    config = ConfigParser()
    config.read(config_file)

    detect_font = font.nametofont("TkDefaultFont")  # Get default font value into Font object
    set_font = detect_font.actual().get("family")
    # set_font_size = detect_font.actual().get("size")

    try:
        stream_win_text_area.config(state=NORMAL)
        stream_win_text_area.delete(1.0, END)
    except (NameError, TclError):
        stream_window = Toplevel()
        stream_window.title("Audio Streams")
        stream_window.configure(background="#434547")
        stream_window.resizable(False, False)  # Disable resize of this window
        if config['save_window_locations']['audio window - view streams - position'] != '' and \
                config['save_window_locations']['audio window - view streams'] == 'yes':
            stream_window.geometry(config['save_window_locations']['audio window - view streams - position'])
        stream_window.protocol('WM_DELETE_WINDOW', exit_stream_window)
        stream_window.grid_columnconfigure(0, weight=1)
        stream_window.grid_rowconfigure(0, weight=1)

        stream_window_frame = LabelFrame(stream_window, text=' Audio Streams ', labelanchor="n")
        stream_window_frame.grid(column=0, row=0, columnspan=1, padx=5, pady=(0, 3), sticky=N + S + E + W)
        stream_window_frame.configure(fg="#3498db", bg="#434547", bd=3, font=(set_font, 10, "bold"))
        stream_window_frame.grid_rowconfigure(0, weight=1)
        stream_window_frame.grid_columnconfigure(0, weight=1)

        stream_win_text_area = scrolledtext.ScrolledText(stream_window_frame, width=80, height=25, tabs=10, spacing2=3,
                                                         spacing1=2, spacing3=3)
        stream_win_text_area.config(bg='black', fg='#CFD2D1', bd=8)
        stream_win_text_area.grid(column=0, pady=5, padx=5, sticky=N + E + S + W)

    character_space = 30  # Can be changed to adjust space of all items in the list automatically
    media_info = MediaInfo.parse(video_input)  # Uses pymediainfo to get information for track selection
    for track in media_info.tracks:  # For loop to loop through mediainfo tracks
        # Formatting --------------------------------------------------------------------------------------------------
        if track.track_type == 'Audio':  # Only grab audio track information
            if str(track.stream_identifier) != 'None':  # Gets stream #
                audio_track_id_space = 'Track#' + ' ' * int(f'{character_space - len("Track#")}')
                audio_track_id = audio_track_id_space + f': {str(int(track.stream_identifier) + 1)}\n'
            else:
                audio_track_id = ''
            if str(track.format) != 'None':  # Gets format string of tracks (aac, ac3 etc...)
                audio_format_space = 'Codec' + ' ' * int(f'{character_space - len("Codec")}')
                audio_format = audio_format_space + f": {str(track.commercial_name)} - ({str(track.format).lower()})\n"
            else:
                audio_format = ''
            if str(track.channel_s) != 'None':  # Gets audio channels of input tracks
                audio_channel_space = 'Channels' + ' ' * int(f'{character_space - len("Channels")}')
                if str(track.channel_s) == '8':
                    show_channels = '7.1'
                elif str(track.channel_s) == '6':
                    show_channels = '5.1'
                elif str(track.channel_s) == '3':
                    show_channels = '2.1'
                else:
                    show_channels = str(track.channel_s)
                audio_channels = audio_channel_space + f": {show_channels} - {str(track.channel_layout)}\n"
            else:
                audio_channels = ''
            if str(track.bit_rate_mode) != 'None':  # Gets audio bit rate mode
                audio_bitrate_mode_space = 'Bit rate mode' + ' ' * int(f'{character_space - len("Bit rate mode")}')
                if str(track.other_bit_rate_mode) != 'None':  # Get secondary string of audio bit rate mode
                    audio_bitrate_mode = audio_bitrate_mode_space + f": {str(track.bit_rate_mode)} / " \
                                                                    f"{str(track.other_bit_rate_mode[0])}\n"
                else:
                    audio_bitrate_mode = audio_bitrate_mode_space + f": {str(track.bit_rate_mode)}\n"
            else:
                audio_bitrate_mode = ''
            if str(track.other_bit_rate) != 'None':  # Gets audio bit rate of input tracks
                audio_bitrate_space = 'Bit rate' + ' ' * int(f'{character_space - len("Bit rate")}')
                audio_bitrate = audio_bitrate_space + f": {str(track.other_bit_rate[0])}\n"
            else:
                audio_bitrate = ''
            if str(track.other_language) != 'None':  # Gets audio language of input tracks
                audio_language_space = 'Language' + ' ' * int(f'{character_space - len("Language")}')
                audio_language = audio_language_space + f": {str(track.other_language[0])}\n"
            else:
                audio_language = ''
            if str(track.title) != 'None':  # Gets audio title of input tracks
                audio_title_space = 'Title' + ' ' * int(f'{character_space - len("Title")}')
                if len(str(track.title)) > 40:  # Counts title character length
                    audio_title = audio_title_space + f": {str(track.title)[:40]}...\n"  # If title > 40 characters
                else:
                    audio_title = audio_title_space + f": {str(track.title)}\n"  # If title is < 40 characters
            else:
                audio_title = ''
            if str(track.other_sampling_rate) != 'None':  # Gets audio sampling rate of input tracks
                audio_sampling_rate_space = 'Sampling Rate' + ' ' * int(f'{character_space - len("Sampling Rate")}')
                audio_sampling_rate = audio_sampling_rate_space + f": {str(track.other_sampling_rate[0])}\n"
            else:
                audio_sampling_rate = ''
            if str(track.other_duration) != 'None':  # Gets audio duration of input tracks
                audio_duration_space = 'Duration' + ' ' * int(f'{character_space - len("Duration")}')
                audio_duration = audio_duration_space + f": {str(track.other_duration[0])}\n"
            else:
                audio_duration = ''
            if str(track.delay) != 'None':  # Gets audio delay of input tracks
                if str(track.delay) == '0':
                    audio_delay = ''
                else:
                    audio_delay_space = 'Delay' + ' ' * int(f'{character_space - len("Delay")}')
                    audio_del_to_vid_space = 'Delay to Video' + ' ' * int(f'{character_space - len("Delay to Video")}')
                    audio_delay = audio_delay_space + f': {str(track.delay)}ms\n' \
                                  + audio_del_to_vid_space + f': {str(track.delay_relative_to_video)}ms\n '
            else:
                audio_delay = ''
            if str(track.other_stream_size) != 'None':  # Get tracks stream size
                audio_track_size_space = 'Stream size' + ' ' * int(f'{character_space - len("Stream size")}')
                audio_track_stream_size = audio_track_size_space + f": {str(track.other_stream_size[4])}\n"
            else:
                audio_track_stream_size = ''
            if str(track.other_bit_depth) != 'None':  # Get tracks bit-depth
                audio_track_b_depth_space = 'Bit Depth' + ' ' * int(f'{character_space - len("Bit Depth")}')
                audio_track_bit_depth = audio_track_b_depth_space + f": {(track.other_bit_depth[0])}\n"
            else:
                audio_track_bit_depth = ''
            if str(track.compression_mode) != 'None':
                audio_track_compression_space = 'Compression' + ' ' * int(f'{character_space - len("Compression")}')
                audio_track_compression = audio_track_compression_space + f": {str(track.compression_mode)}\n"
            else:
                audio_track_compression = ''
            if str(track.default) != 'None':  # Get tracks default boolean
                audio_track_default_space = 'Default' + ' ' * int(f'{character_space - len("Default")}')
                audio_track_default = audio_track_default_space + f": {str(track.default)}\n"
            else:
                audio_track_default = ''
            if str(track.forced) != 'None':  # Get tracks forced boolean
                audio_track_forced_space = 'Forced' + ' ' * int(f'{character_space - len("Forced")}')
                audio_track_forced = audio_track_forced_space + f": {str(track.forced)}"
            else:
                audio_track_forced = ''

            # ---------------------------------------------------------------------------------------------- Formatting
            audio_track_info = str(audio_track_id + audio_format + audio_channels + audio_bitrate_mode +
                                   audio_bitrate + audio_sampling_rate + audio_delay + audio_duration +
                                   audio_language + audio_title + audio_track_stream_size + audio_track_bit_depth +
                                   audio_track_compression + audio_track_default + audio_track_forced)  # Formatting
            media_info_track_string = 80 * '#' + '\n' + audio_track_info + '\n' + 80 * '#' + '\n'  # String to insert
            stream_win_text_area.configure(state=NORMAL)  # Enable textbox
            stream_win_text_area.insert(INSERT, media_info_track_string)  # Insert string
            stream_win_text_area.insert(INSERT, '\n')  # Insert a newline
            stream_win_text_area.configure(state=DISABLED)  # Disable textbox

    def right_click_menu_func(x_y_pos):  # Function for mouse button 3 (right click) to pop up menu
        right_click_menu.tk_popup(x_y_pos.x_root, x_y_pos.y_root)  # This gets the position of cursor

    def copy_selected_text():  # Function to copy only selected text
        pya_hotkey('ctrl', 'c')
        time_sleep(.01)  # Slow program incase ctrl+c is slower

    right_click_menu = Menu(stream_window, tearoff=False)  # This is the right click menu
    right_click_menu.add_command(label='Copy Selected Text', command=copy_selected_text)
    right_click_menu.add_command(label='Copy All Text', command=pyperclip_copy(stream_win_text_area.get(1.0, END)))
    stream_window.bind('<Button-3>', right_click_menu_func)  # Uses mouse button 3 (right click) to pop up menu
    Hovertip(stream_win_text_area, 'Right click to copy', hover_delay=1200)  # Hover tip tool-tip
Exemplo n.º 24
0
    def editar_pedido_inventario(self):
        conn = sqlite3.connect('inventario.db')
        cursor = conn.cursor()
        query = ("SELECT PRECIO_VENTA FROM producto WHERE ID_PRODUCTO = ?")
        parametros = self.id_pro.get()
        cursor.execute(query, (parametros, ))
        precio = cursor.fetchone()
        self.valor_precio1 = precio[0]
        query = ("SELECT DEUDA FROM cliente WHERE CI_CLIENTE = ?")
        parametros = (self.ci.get())
        cursor.execute(query, (parametros, ))
        self.deuda2 = cursor.fetchone()
        self.valor_deuda1 = self.deuda2[0]
        parametros = (self.id_pro.get(), self.cant.get(), self.dia(),
                      self.ci_pedido_v)
        query = (
            "UPDATE pedido SET ID_PRODUCTO = ? , CANTIDAD_PEDIDO = ?, FECHA = ? WHERE CI_CLIENTE = ?"
        )
        cursor.execute(query, parametros)
        precio1 = cursor.fetchone()
        self.valor_precio1 = precio[0]
        if self.cant.get() < self.cant_v1:
            if len(self.cant.get()) != 0:

                query = "SELECT CANTIDAD_PRODUCTO FROM producto WHERE ID_PRODUCTO = ?"
                parametros = (self.Id_operacion1)
                print(parametros)
                cursor.execute(query, (parametros, ))
                fetchone_cantidad = cursor.fetchone()
                cant_producto_v = fetchone_cantidad[0]
                cant_n1 = int(self.cant.get())
                self.inventario_resta = (int(self.cant_v1) - cant_n1)
                self.inventario_operacion = self.inventario_resta + cant_producto_v

                query = "UPDATE producto SET CANTIDAD_PRODUCTO = ? WHERE ID_PRODUCTO = ?"
                parametros = (self.inventario_operacion, self.Id_operacion1)
                print(self.inventario_operacion)
                cursor.execute(query, parametros)
                self.total1 = (self.inventario_resta *
                               self.valor_precio1) - self.valor_deuda1

                query = "UPDATE cliente SET DEUDA = ? WHERE CI_CLIENTE = ?"
                parametros = (self.total1, self.ci.get())
                cursor.execute(query, parametros)

                messagebox.showinfo("BASE DE DATOS",
                                    "Se han actualizado los campos")

        elif self.cant.get() > self.cant_v1:
            if len(self.cant.get()) != 0:

                query = "SELECT CANTIDAD_PRODUCTO FROM producto WHERE ID_PRODUCTO = ?"
                parametros = (self.Id_operacion1)
                cursor.execute(query, (parametros, ))
                fetchone_cantidad = cursor.fetchone()
                cant_producto_v = fetchone_cantidad[0]
                cant_n1 = int(self.cant.get())
                self.inventario_resta = (int(self.cant_v1) - cant_n1)
                self.inventario_operacion = self.inventario_resta - cant_producto_v

                query = "UPDATE producto SET CANTIDAD_PRODUCTO = ? WHERE ID_PRODUCTO = ?"
                parametros = (self.inventario_operacion, self.Id_operacion1)
                cursor.execute(query, parametros)
                self.total1 = (self.inventario_resta *
                               self.valor_precio1) + self.valor_deuda1

                query = "UPDATE cliente SET DEUDA = ? WHERE CI_CLIENTE = ?"
                parametros = (self.total1, self.ci.get())
                cursor.execute(query, parametros)
                messagebox.showinfo("BASE DE DATOS",
                                    "Se han actualizado los campos")
        else:
            messagebox.showerror("BASE DE DATOS",
                                 "El campo cantidad no puede estar en blanco")
        self.ci.configure(state='normal')
        self.obt_pedidos()
        self.clean_pedido()
        Hovertip(self.ci,
                 text="No puede actualizar la CI de los pedidos ya ingresados",
                 hover_delay=360000)
Exemplo n.º 25
0
    def windclientes(self):
        self.wind.iconify()
        self.windclientes1 = Toplevel()
        self.windclientes1.resizable(width=0, height=0)
        self.windclientes1.geometry("900x550+200+50")
        self.windclientes1.iconbitmap('archivo.ico')
        self.windclientes1.title("Clientes")

        self.tree1 = ttk.Treeview(self.windclientes1)
        self.tree1['columns'] = ("CI_CLIENTE", "NONMBRE", "APELLIDO",
                                 "TELEFONO", "DIRECCION", "DEUDA")
        self.tree1.place(x=0, y=270)
        self.tree1.bind("<Double-Button-1>", self.seleccionar1_click)
        self.tree1.column('#0', width=0, stretch=NO)
        self.tree1.column('#1', minwidth=150, width=150, anchor=CENTER)
        self.tree1.column('#2', minwidth=150, width=150, anchor=CENTER)
        self.tree1.column('#3', minwidth=150, width=150, anchor=CENTER)
        self.tree1.column('#4', minwidth=150, width=150, anchor=CENTER)
        self.tree1.column('#5', minwidth=150, width=150, anchor=CENTER)
        self.tree1.column('#6', minwidth=150, width=150, anchor=CENTER)
        self.tree1.heading('#1', text='CEDULA', anchor=CENTER)
        self.tree1.heading('#2', text='NOMBRE', anchor=CENTER)
        self.tree1.heading('#3', text='APELLIDO', anchor=CENTER)
        self.tree1.heading('#4', text='TELEFONO', anchor=CENTER)
        self.tree1.heading('#5', text='DIRECCION', anchor=CENTER)
        self.tree1.heading('#6', text='DEUDA', anchor=CENTER)
        self.obt_clientes()

        self.l_title = Label(self.windclientes1, text="Agregue un cliente")
        self.l_title.place(x=(self.xe), y=self.ye)

        self.l_ci_cedula = Label(self.windclientes1, text="Cedula: ")
        self.l_ci_cedula.place(x=376, y=40)
        self.ci_cliente = Entry(self.windclientes1, width=30)
        self.ci_cliente.focus()
        self.ci_cliente.place(x=(self.xe + 60), y=(self.ye + 25))

        self.l_nombre = Label(self.windclientes1, text="nombre: ")
        self.l_nombre.place(x=370, y=70)
        self.nombre = Entry(self.windclientes1, width=30)
        self.nombre.place(x=(self.xe + 60), y=(self.ye + 55))

        self.l_apellido = Label(self.windclientes1, text="apellido: ")
        self.l_apellido.place(x=370, y=100)
        self.apellido = Entry(self.windclientes1, width=30)
        self.apellido.place(x=(self.xe + 60), y=(self.ye + 85))

        self.l_telefono = Label(self.windclientes1, text="telefono: ")
        self.l_telefono.place(x=370, y=130)
        self.telefono = Entry(self.windclientes1, width=30)
        self.telefono.place(x=(self.xe + 60), y=(self.ye + 115))

        self.l_direccion = Label(self.windclientes1, text="direccion: ")
        self.l_direccion.place(x=366, y=160)
        self.direccion = Entry(self.windclientes1, width=30)
        self.direccion.place(x=(self.xe + 60), y=(self.ye + 145))

        self.l_deuda = Label(self.windclientes1, text="deuda: ")
        self.l_deuda.place(x=382, y=190)
        self.deuda = Entry(self.windclientes1, width=30)
        self.deuda.place(x=(self.xe + 60), y=(self.ye + 175))

        self.b_guardar = ttk.Button(self.windclientes1,
                                    text="Guardar cliente",
                                    width=70,
                                    command=self.agregar_cliente)
        self.b_guardar.place(x=(self.xe - 170), y=(self.ye + 210))

        self.b_eliminar = ttk.Button(self.windclientes1,
                                     text="Eliminar cliente",
                                     width=70,
                                     command=self.eliminar_cliente)
        self.b_eliminar.place(x=(self.xe + 35), y=(self.ye + 500))
        self.b_eliminar['state'] = 'disable'

        self.b_actualizar = ttk.Button(self.windclientes1,
                                       text="Actualizar cliente",
                                       width=70,
                                       command=self.editar_cliente)
        self.b_actualizar.place(x=30, y=(self.ye + 500))
        self.b_actualizar['state'] = 'disable'

        self.bpsearch = Button(self.windclientes1,
                               width=35,
                               height=35,
                               command=self.buscar_cliente)
        self.bpsearch.config(image=self.img)
        self.bpsearch.place(x=15, y=15)
        Hovertip(self.bsearch, text="BUSCAR")

        self.img7 = PhotoImage(file='home.png')
        self.bprin_cliente = Button(self.windclientes1,
                                    width=35,
                                    height=35,
                                    command=self.principal_cliente)
        self.bprin_cliente.config(image=self.img7)
        self.bprin_cliente.place(x=15, y=65)
        Hovertip(self.bprin_cliente, text="PANTALLA PRINCIPAL")
Exemplo n.º 26
0
def main():
    if len(sys.argv) == 2 and sys.argv[1] == '--create-shortcut':
        create_shortcut()
        return
    window = tk.Tk()
    window.title('AA_stat GUI')
    window.geometry('900x600')
    try:
        try:
            window.tk.call('tk_getOpenFile', '-foobarbaz')
        except tk.TclError:
            pass

        window.tk.call('set', '::tk::dialog::file::showHiddenBtn', '1')
        window.tk.call('set', '::tk::dialog::file::showHiddenVar', '0')
    except:
        pass

    top_frame = tk.Frame()
    input_frame = tk.Frame(master=top_frame)

    spectra_frame = tk.Frame(master=top_frame)
    selected_spectra_lbl = tk.Label(master=spectra_frame,
                                    text="(optional)",
                                    justify='left')

    get_spectra_btn = tk.Button(master=spectra_frame,
                                text="Select mzML or MGF files",
                                command=partial(get_spectrum_filenames,
                                                selected_spectra_lbl),
                                width=20)
    spectra_tip_text = (
        "If you provide original mzML or MGF files,\n"
        "AA_stat will perform MS/MS-based localization of mass shifts\nand recommend variable modifications."
    )
    Hovertip(spectra_frame, text=spectra_tip_text)

    get_spectra_btn.pack(side=tk.LEFT, anchor=tk.E)
    selected_spectra_lbl.pack(side=tk.LEFT, padx=15, anchor=tk.W)

    dir_frame = tk.Frame(master=top_frame)
    dir_lbl = tk.Label(master=dir_frame,
                       text="Output directory: " + os.path.abspath(OUTDIR),
                       justify='left')
    get_dir_btn = tk.Button(master=dir_frame,
                            text="Select output directory",
                            command=partial(get_outdir_name, dir_lbl),
                            width=20)

    get_dir_btn.pack(side=tk.LEFT, anchor=tk.E)
    dir_lbl.pack(side=tk.LEFT, anchor=tk.W, padx=15)

    main_frame = tk.Frame()
    run_btn = tk.Button(master=main_frame,
                        text='Run AA_stat',
                        state=tk.DISABLED)

    status_lbl = tk.Label(master=main_frame, text=get_aa_stat_version())
    log_txt = ScrolledText(master=main_frame, state=tk.DISABLED)
    t = threading.Thread(target=run_aastat,
                         args=(run_btn, status_lbl, log_txt),
                         name='aastat-runner')
    t.daemon = True
    run_btn['command'] = partial(start_aastat, t)

    AAstatHandler = logutils.get_aastat_handler(log_txt)

    log_t = threading.Thread(target=logutils._socket_listener_worker,
                             args=(logger,
                                   logging.handlers.DEFAULT_TCP_LOGGING_PORT,
                                   AAstatHandler),
                             name='aastat-listener')
    log_t.start()
    logger.debug('AA_stat logging initiated.')

    log_txt.pack(fill=tk.BOTH, expand=True)
    run_btn.pack()
    status_lbl.pack()

    selected_os_lbl = tk.Label(master=input_frame,
                               text="No files selected",
                               justify='left')

    get_os_files_btn = tk.Button(master=input_frame,
                                 text="Select open search files",
                                 command=partial(get_input_filenames,
                                                 selected_os_lbl, run_btn),
                                 width=20)

    get_os_files_btn.pack(side=tk.LEFT, anchor=tk.E)
    selected_os_lbl.pack(side=tk.LEFT, padx=15, anchor=tk.W)
    Hovertip(input_frame,
             text="Specify open search results in pepXML or CSV format.")

    params_frame = tk.Frame(master=top_frame)
    params_lbl = tk.Label(master=params_frame,
                          text="Using default parameters.")
    load_params_btn = tk.Button(master=params_frame,
                                width=10,
                                padx=4,
                                text="Load params",
                                command=partial(get_params, params_lbl))
    edit_params_btn = tk.Button(master=params_frame,
                                width=10,
                                padx=4,
                                text="Edit params",
                                command=partial(edit_params, window,
                                                params_lbl))

    load_params_btn.pack(side=tk.LEFT, fill=tk.X, anchor=tk.E)
    edit_params_btn.pack(side=tk.LEFT, fill=tk.X, anchor=tk.E)
    params_lbl.pack(side=tk.LEFT, fill=tk.X, anchor=tk.W, padx=15)

    input_frame.pack(side=tk.TOP, fill=tk.X, expand=True)
    spectra_frame.pack(side=tk.TOP, fill=tk.X, expand=True)
    dir_frame.pack(side=tk.TOP, fill=tk.X, expand=True)
    params_frame.pack(side=tk.TOP, fill=tk.X, expand=True)

    top_frame.pack()
    main_frame.pack(fill=tk.BOTH, expand=True)
    if not AA_STAT_VERSION:
        for btn in [get_spectra_btn, get_os_files_btn, get_dir_btn]:
            btn['state'] = tk.DISABLED
    window.mainloop()
    if PARAMS_TMP:
        logger.debug('Removing temporary file %s', PARAMS_TMP)
        os.remove(PARAMS_TMP)
    logutils.tcpserver.abort = 1
    logutils.tcpserver.server_close()
    sys.exit()  # needed because there are still working (daemon) threads
Exemplo n.º 27
0
    def attach_settings(self, settings) -> None:
        if not settings.GUIEnabled:
            return

        self.settings = settings

        # ---------------------------
        # Tabs
        # ---------------------------
        tab2 = Frame(self.tab_control)
        # tab3 = Frame(self.tab_control)
        tab4 = Frame(self.tab_control)
        # tab5 = Frame(self.tab_control)

        self.tab_control.add(tab2, text="Login")
        # self.tab_control.add(tab3, text="General")
        self.tab_control.add(tab4, text="Mascot")
        # self.tab_control.add(tab5, text="Hardware")
        self.tab_control.select(
            0
        )  ###################################################################################################

        # ---------------------------
        # [Tab] Login
        # ---------------------------
        def cmd_reconnect_broadcaster():
            if hasattr(self.twitch, "connected") and self.twitch.connected:
                self.twitch.disconnect()

        def cmd_reconnect_chatbot():
            if hasattr(self.chatbot, "connected") and self.chatbot.connected:
                self.chatbot.disconnect()

        def cmd_save_broadcaster():
            tmp_oauth = broadcaster_oauth_var.get()
            if tmp_oauth.find("oauth:") != 0:
                messagebox.showerror(title="Error", message="OAUTH is invalid")
                return 1

            self.settings.TwitchOAUTH = tmp_oauth
            self.settings.save()

        def cmd_save_chatbot():
            tmp_oauth = chatbot_oauth_var.get()
            if tmp_oauth.find("oauth:") != 0:
                messagebox.showerror(title="Error", message="OAUTH is invalid")
                return 1

            self.settings.TwitchBotOAUTH = tmp_oauth
            self.settings.save()

        def callback_url(url):
            webbrowser.open_new(url)

        # [Tab] Login - Broadcaster
        frame_twitch = LabelFrame(tab2, text="Twitch account", padx=5, pady=5)
        frame_twitch.grid(row=0, column=0, padx=2, pady=2, sticky=["NSWE"])
        tab2.grid_rowconfigure(0, weight=1)
        tab2.grid_columnconfigure([0, 1], weight=1)

        Label(frame_twitch, text="OAUTH").grid(row=0, column=0, sticky=E)

        broadcaster_oauth_var = tk.StringVar()
        broadcaster_oauth_var.set(self.settings.TwitchOAUTH)
        broadcaster_oauth = Entry(frame_twitch,
                                  textvariable=broadcaster_oauth_var,
                                  show="*",
                                  width=30)
        broadcaster_oauth.grid(row=0, column=1)

        broadcaster_oauth_link = Label(frame_twitch,
                                       text="Obtain a Twitch OAUTH",
                                       fg="blue",
                                       cursor="hand2")
        broadcaster_oauth_link.bind(
            "<Button-1>",
            lambda e: callback_url("https://www.twitchapps.com/tmi/"))
        broadcaster_oauth_link.grid(row=1, column=1, sticky=E)

        broadcaster_save = Button(frame_twitch,
                                  text="Save",
                                  width=15,
                                  command=cmd_save_broadcaster)
        broadcaster_save.grid(row=2, column=1, sticky=E)

        broadcaster_reconnect = Button(
            frame_twitch,
            text="Reconnect Twitch",
            width=15,
            command=cmd_reconnect_broadcaster,
        )
        broadcaster_reconnect.tooltip = Hovertip(
            frame_twitch,
            "Reconnect broadcaster twitch account",
            hover_delay=100)
        broadcaster_reconnect.grid(row=10, column=1, sticky=E, pady=15)

        # [Tab] Login - chatbot
        frame_chatbotbot = LabelFrame(tab2,
                                      text="Chatbot account",
                                      padx=5,
                                      pady=5)
        frame_chatbotbot.grid(row=0, column=1, padx=2, pady=2, sticky=["NSWE"])

        Label(frame_chatbotbot, text="OAUTH").grid(row=0, column=0, sticky=E)

        chatbot_oauth_var = tk.StringVar()
        chatbot_oauth_var.set(self.settings.TwitchBotOAUTH)
        chatbot_oauth = Entry(frame_chatbotbot,
                              textvariable=chatbot_oauth_var,
                              show="*",
                              width=30)
        chatbot_oauth.grid(row=0, column=1)

        chatbot_oauth_link = Label(frame_chatbotbot,
                                   text="Obtain a Twitch OAUTH",
                                   fg="blue",
                                   cursor="hand2")
        chatbot_oauth_link.bind(
            "<Button-1>",
            lambda e: callback_url("https://www.twitchapps.com/tmi/"))
        chatbot_oauth_link.grid(row=1, column=1, sticky=E)

        chatbot_save = Button(frame_chatbotbot,
                              text="Save",
                              width=15,
                              command=cmd_save_chatbot)
        chatbot_save.grid(row=2, column=1, sticky=E)

        chatbot_reconnect = Button(
            frame_chatbotbot,
            text="Reconnect Chatbot",
            width=15,
            command=cmd_reconnect_chatbot,
        )
        chatbot_reconnect.tooltip = Hovertip(
            frame_chatbotbot,
            "Reconnect chatbot twitch account",
            hover_delay=100)
        chatbot_reconnect.grid(row=10, column=1, sticky=E, pady=15)

        # ---------------------------
        # [Tab] Mascot
        # ---------------------------
        frame_mascot_general = LabelFrame(tab4, text="General", padx=5, pady=5)
        frame_mascot_general.grid(row=0,
                                  column=0,
                                  padx=2,
                                  pady=2,
                                  sticky=["NSWE"])
        frame_mascot_style = LabelFrame(tab4,
                                        text="Speech bubble styles",
                                        padx=5,
                                        pady=5)
        frame_mascot_style.grid(row=0,
                                column=1,
                                padx=2,
                                pady=2,
                                sticky=["NSWE"])
        tab4.grid_rowconfigure(0, weight=1)
        tab4.grid_columnconfigure([0, 1], weight=1)

        def cmd_save_mascot():
            self.settings.CurrentMascot = mascot_mascot.get()
            self.settings.AlignMascot = mascot_align.get()
            self.settings.Styles[
                "BackgroundColor"] = styles_backgroundcolor_var.get()
            self.settings.Styles["BorderColor"] = styles_bordercolor_var.get()
            self.settings.Styles["BorderWidth"] = styles_borderwidth_var.get()
            self.settings.Styles["BorderRadius"] = styles_borderradius_var.get(
            )
            self.settings.Styles[
                "BorderStrokeColor"] = styles_borderstrokecolor_var.get()
            self.settings.Styles["TextFontFamily"] = styles_textfontfamily.get(
            )
            self.settings.Styles["TextSize"] = styles_textsize_var.get()
            self.settings.Styles["TextWeight"] = styles_textweight_var.get()
            self.settings.Styles["TextColor"] = styles_textcolor_var.get()
            self.settings.Styles[
                "HighlightTextSize"] = styles_highlighttextsize_var.get()
            self.settings.Styles[
                "HighlightTextSpacing"] = styles_highlighttextspacing_var.get(
                )
            self.settings.Styles[
                "HighlightTextColor"] = styles_highlighttextcolor_var.get()
            self.settings.Styles[
                "HighlightTextStrokeColor"] = styles_highlighttextstrokecolor_var.get(
                )
            self.settings.Styles[
                "HighlightTextShadowColor"] = styles_highlighttextshadowcolor_var.get(
                )
            self.settings.Styles[
                "HighlightTextShadowOffset"] = styles_highlighttextshadowoffset_var.get(
                )
            self.settings.save()
            self.settings.reload_mascot()
            self.overlay.reload()

        mascot_save = Button(tab4,
                             text="Save",
                             width=15,
                             command=cmd_save_mascot)
        mascot_save.grid(row=1, column=1, sticky=E)

        # [Tab] Mascot - General
        mascot_list = []
        mascot_list_value = None
        mascot_dir = self.settings.pathRoot + "mascots" + self.settings.slash
        for idir in listdir(mascot_dir):
            if not path.isdir(path.join(mascot_dir, idir)):
                continue
            mascot_list.append(idir)

        mascot_list.sort()
        for index, value in enumerate(mascot_list):
            if value == self.settings.CurrentMascot:
                mascot_list_value = index

        Label(frame_mascot_general, text="Current Mascot").grid(row=0,
                                                                column=0,
                                                                sticky=E)
        mascot_mascot = ttk.Combobox(frame_mascot_general,
                                     values=mascot_list,
                                     width=26)
        mascot_mascot.grid(row=0, column=1, sticky=W)
        if mascot_list_value is not None:
            mascot_mascot.current(mascot_list_value)

        mascot_align_list = ["left", "right"]
        mascot_align_list_value = None
        for index, value in enumerate(mascot_align_list):
            if value == self.settings.AlignMascot:
                mascot_align_list_value = index

        Label(frame_mascot_general, text="Mascot Alignment").grid(row=1,
                                                                  column=0,
                                                                  sticky=E)
        mascot_align = ttk.Combobox(frame_mascot_general,
                                    values=mascot_align_list,
                                    width=26)
        mascot_align.grid(row=1, column=1, sticky=W)
        if mascot_align_list_value is not None:
            mascot_align.current(mascot_align_list_value)

        # [Tab] Mascot - Style
        def is_hex_color(input_string):
            regexp = re.compile(r"^#([A-Fa-f0-9]{6}|[A-Fa-f0-9]{3})$")
            if regexp.search(input_string):
                return True
            return False

        def cmd_colorchanged(var, field):
            if is_hex_color(str(var.get())):
                field.configure(bg=str(var.get()))

        def cmd_colorpicker(var, field):
            color_code = colorchooser.askcolor(title="Choose color")[1]
            if color_code is not None:
                var.set(color_code)

        Label(frame_mascot_style, text="Background Color").grid(row=0,
                                                                column=0,
                                                                sticky=E)
        styles_backgroundcolor_var = tk.StringVar()
        styles_backgroundcolor_var.set(self.settings.Styles["BackgroundColor"])
        styles_backgroundcolor = Entry(frame_mascot_style,
                                       textvariable=styles_backgroundcolor_var,
                                       width=30)
        styles_backgroundcolor_var.trace_add(
            "write",
            lambda nm, idx, mode, var=styles_backgroundcolor_var, field=
            styles_backgroundcolor: cmd_colorchanged(var, field),
        )
        styles_backgroundcolor.grid(row=0, column=1)
        styles_backgroundcolor.configure(
            bg=str(styles_backgroundcolor_var.get()))
        Button(
            frame_mascot_style,
            text="Pick",
            command=lambda: cmd_colorpicker(styles_backgroundcolor_var,
                                            styles_backgroundcolor),
        ).grid(row=0, column=2, sticky=E)

        Label(frame_mascot_style, text="Border Color").grid(row=1,
                                                            column=0,
                                                            sticky=E)
        styles_bordercolor_var = tk.StringVar()
        styles_bordercolor_var.set(self.settings.Styles["BorderColor"])
        styles_bordercolor = Entry(frame_mascot_style,
                                   textvariable=styles_bordercolor_var,
                                   width=30)
        styles_bordercolor_var.trace_add(
            "write",
            lambda nm, idx, mode, var=styles_bordercolor_var, field=
            styles_bordercolor: cmd_colorchanged(var, field),
        )
        styles_bordercolor.grid(row=1, column=1)
        styles_bordercolor.configure(bg=str(styles_bordercolor_var.get()))
        Button(
            frame_mascot_style,
            text="Pick",
            command=lambda: cmd_colorpicker(styles_bordercolor_var,
                                            styles_bordercolor),
        ).grid(row=1, column=2, sticky=E)

        Label(frame_mascot_style, text="Border Width").grid(row=2,
                                                            column=0,
                                                            sticky=E)
        styles_borderwidth_var = IntVar()
        styles_borderwidth_var.set(self.settings.Styles["BorderWidth"])
        styles_borderwidth = Spinbox(
            frame_mascot_style,
            textvariable=styles_borderwidth_var,
            width=28,
            from_=0,
            to=20,
        )
        styles_borderwidth.grid(row=2, column=1)

        Label(frame_mascot_style, text="Border Radius").grid(row=3,
                                                             column=0,
                                                             sticky=E)
        styles_borderradius_var = IntVar()
        styles_borderradius_var.set(self.settings.Styles["BorderRadius"])
        styles_borderradius = Spinbox(
            frame_mascot_style,
            textvariable=styles_borderradius_var,
            width=28,
            from_=0,
            to=50,
        )
        styles_borderradius.grid(row=3, column=1)

        Label(frame_mascot_style, text="Border Stroke Color").grid(row=4,
                                                                   column=0,
                                                                   sticky=E)
        styles_borderstrokecolor_var = tk.StringVar()
        styles_borderstrokecolor_var.set(
            self.settings.Styles["BorderStrokeColor"])
        styles_borderstrokecolor = Entry(
            frame_mascot_style,
            textvariable=styles_borderstrokecolor_var,
            width=30)
        styles_borderstrokecolor_var.trace_add(
            "write",
            lambda nm, idx, mode, var=styles_borderstrokecolor_var, field=
            styles_borderstrokecolor: cmd_colorchanged(var, field),
        )
        styles_borderstrokecolor.grid(row=4, column=1)
        styles_borderstrokecolor.configure(
            bg=str(styles_borderstrokecolor_var.get()))
        Button(
            frame_mascot_style,
            text="Pick",
            command=lambda: cmd_colorpicker(styles_borderstrokecolor_var,
                                            styles_borderstrokecolor),
        ).grid(row=4, column=2, sticky=E)

        Label(frame_mascot_style, text="Text Font Family").grid(row=5,
                                                                column=0,
                                                                sticky=E)
        font_list = []
        font_list_textfontfamily = None
        for i in font.families():
            if i.startswith("@"):
                continue

            font_list.append(i)

        font_list.sort()

        for index, value in enumerate(font_list):
            if value == self.settings.Styles["TextFontFamily"]:
                font_list_textfontfamily = index

        styles_textfontfamily = ttk.Combobox(frame_mascot_style,
                                             values=font_list,
                                             width=26)
        styles_textfontfamily.grid(row=5, column=1, sticky=W)
        if font_list_textfontfamily is not None:
            styles_textfontfamily.current(font_list_textfontfamily)

        Label(frame_mascot_style, text="Text Size").grid(row=6,
                                                         column=0,
                                                         sticky=E)
        styles_textsize_var = IntVar()
        styles_textsize_var.set(self.settings.Styles["TextSize"])
        styles_textsize = Spinbox(
            frame_mascot_style,
            textvariable=styles_textsize_var,
            width=28,
            from_=8,
            to=60,
        )
        styles_textsize.grid(row=6, column=1)

        Label(frame_mascot_style, text="Text Weight").grid(row=7,
                                                           column=0,
                                                           sticky=E)
        styles_textweight_var = IntVar()
        styles_textweight_var.set(self.settings.Styles["TextWeight"])
        styles_textweight = Spinbox(
            frame_mascot_style,
            textvariable=styles_textweight_var,
            width=28,
            from_=1,
            to=1000,
        )
        styles_textweight.grid(row=7, column=1)

        Label(frame_mascot_style, text="Text Color").grid(row=8,
                                                          column=0,
                                                          sticky=E)
        styles_textcolor_var = tk.StringVar()
        styles_textcolor_var.set(self.settings.Styles["TextColor"])
        styles_textcolor = Entry(frame_mascot_style,
                                 textvariable=styles_textcolor_var,
                                 width=30)
        styles_textcolor_var.trace_add(
            "write",
            lambda nm, idx, mode, var=styles_textcolor_var, field=
            styles_textcolor: cmd_colorchanged(var, field),
        )
        styles_textcolor.grid(row=8, column=1)
        styles_textcolor.configure(bg=str(styles_textcolor_var.get()))
        Button(
            frame_mascot_style,
            text="Pick",
            command=lambda: cmd_colorpicker(styles_textcolor_var,
                                            styles_textcolor),
        ).grid(row=8, column=2, sticky=E)

        Label(frame_mascot_style, text="Highlight Text Size").grid(row=9,
                                                                   column=0,
                                                                   sticky=E)
        styles_highlighttextsize_var = IntVar()
        styles_highlighttextsize_var.set(
            self.settings.Styles["HighlightTextSize"])
        styles_highlighttextsize = Spinbox(
            frame_mascot_style,
            textvariable=styles_highlighttextsize_var,
            width=28,
            from_=8,
            to=60,
        )
        styles_highlighttextsize.grid(row=9, column=1)

        Label(frame_mascot_style, text="Highlight Text Spacing").grid(row=10,
                                                                      column=0,
                                                                      sticky=E)
        styles_highlighttextspacing_var = IntVar()
        styles_highlighttextspacing_var.set(
            self.settings.Styles["HighlightTextSpacing"])
        styles_highlighttextspacing = Spinbox(
            frame_mascot_style,
            textvariable=styles_highlighttextspacing_var,
            width=28,
            from_=0,
            to=10,
        )
        styles_highlighttextspacing.grid(row=10, column=1)

        Label(frame_mascot_style, text="Highlight Text Color").grid(row=11,
                                                                    column=0,
                                                                    sticky=E)
        styles_highlighttextcolor_var = tk.StringVar()
        styles_highlighttextcolor_var.set(
            self.settings.Styles["HighlightTextColor"])
        styles_highlighttextcolor = Entry(
            frame_mascot_style,
            textvariable=styles_highlighttextcolor_var,
            width=30)
        styles_highlighttextcolor_var.trace_add(
            "write",
            lambda nm, idx, mode, var=styles_highlighttextcolor_var, field=
            styles_highlighttextcolor: cmd_colorchanged(var, field),
        )
        styles_highlighttextcolor.grid(row=11, column=1)
        styles_highlighttextcolor.configure(
            bg=str(styles_highlighttextcolor_var.get()))
        Button(
            frame_mascot_style,
            text="Pick",
            command=lambda: cmd_colorpicker(styles_highlighttextcolor_var,
                                            styles_highlighttextcolor),
        ).grid(row=11, column=2, sticky=E)

        Label(frame_mascot_style,
              text="Highlight Text Stroke Color").grid(row=12,
                                                       column=0,
                                                       sticky=E)
        styles_highlighttextstrokecolor_var = tk.StringVar()
        styles_highlighttextstrokecolor_var.set(
            self.settings.Styles["HighlightTextStrokeColor"])
        styles_highlighttextstrokecolor = Entry(
            frame_mascot_style,
            textvariable=styles_highlighttextstrokecolor_var,
            width=30,
        )
        styles_highlighttextstrokecolor_var.trace_add(
            "write",
            lambda nm, idx, mode, var=styles_highlighttextstrokecolor_var,
            field=styles_highlighttextstrokecolor: cmd_colorchanged(
                var, field),
        )
        styles_highlighttextstrokecolor.grid(row=12, column=1)
        styles_highlighttextstrokecolor.configure(
            bg=str(styles_highlighttextstrokecolor_var.get()))
        Button(
            frame_mascot_style,
            text="Pick",
            command=lambda: cmd_colorpicker(
                styles_highlighttextstrokecolor_var,
                styles_highlighttextstrokecolor),
        ).grid(row=12, column=2, sticky=E)

        Label(frame_mascot_style,
              text="Highlight Text Shadow Color").grid(row=13,
                                                       column=0,
                                                       sticky=E)
        styles_highlighttextshadowcolor_var = tk.StringVar()
        styles_highlighttextshadowcolor_var.set(
            self.settings.Styles["HighlightTextShadowColor"])
        styles_highlighttextshadowcolor = Entry(
            frame_mascot_style,
            textvariable=styles_highlighttextshadowcolor_var,
            width=30,
        )
        styles_highlighttextshadowcolor_var.trace_add(
            "write",
            lambda nm, idx, mode, var=styles_highlighttextshadowcolor_var,
            field=styles_highlighttextshadowcolor: cmd_colorchanged(
                var, field),
        )
        styles_highlighttextshadowcolor.grid(row=13, column=1)
        styles_highlighttextshadowcolor.configure(
            bg=str(styles_highlighttextshadowcolor_var.get()))
        Button(
            frame_mascot_style,
            text="Pick",
            command=lambda: cmd_colorpicker(
                styles_highlighttextshadowcolor_var,
                styles_highlighttextshadowcolor),
        ).grid(row=13, column=2, sticky=E)

        Label(frame_mascot_style,
              text="Highlight Text Shadow Offset").grid(row=14,
                                                        column=0,
                                                        sticky=E)
        styles_highlighttextshadowoffset_var = IntVar()
        styles_highlighttextshadowoffset_var.set(
            self.settings.Styles["HighlightTextShadowOffset"])
        styles_highlighttextshadowoffset = Spinbox(
            frame_mascot_style,
            textvariable=styles_highlighttextshadowoffset_var,
            width=28,
            from_=0,
            to=20,
        )
        styles_highlighttextshadowoffset.grid(row=14, column=1)
Exemplo n.º 28
0
 def test_hidetip(self):
     tooltip = Hovertip(self.button, 'ToolTip text')
     self.addCleanup(tooltip.hidetip)
     tooltip.showtip()
     tooltip.hidetip()
     self.assertFalse(self.is_tipwindow_shown(tooltip))
Exemplo n.º 29
0
    def __init__(self, root):
        self.root = root
        self.attach = []
        self.to_email_list = []
        self.user_email = ''
        self.user_password = ''

        label = Label(self.root, bg='#BCF8EA', bd=5, relief=FLAT)
        label.pack(fill=BOTH)

        self.main_frame = Frame(self.root, width=600, bd=5, relief=GROOVE)
        self.main_frame.pack(side=LEFT, fil=Y)

        self.to_label = Label(self.main_frame, text="To", font='Calibri')
        self.to_label.place(x=0, y=10)

        self.to_entry = Entry(self.main_frame, font='Calibri', width=45, bd=2)
        self.to_entry.place(x=75, y=10)
        self.to_entry.config(state='disabled')

        self.csv_attach_btn = Button(self.main_frame,
                                     text='Import Email List',
                                     command=self.select_csv)
        self.csv_attach_btn.place(x=460, y=10)
        myTip = Hovertip(self.csv_attach_btn,
                         'Import a list of emails as a CSV file.')
        self.csv_attach_btn.config(state='disabled')

        self.subject_label = Label(self.main_frame,
                                   text="Subject",
                                   font='Calibri')
        self.subject_label.place(x=0, y=40)

        self.subject_entry = Entry(self.main_frame,
                                   font='Calibri',
                                   width=45,
                                   bd=2)
        self.subject_entry.place(x=75, y=40)
        self.subject_entry.config(state='disabled')

        self.text_frame = Frame(self.main_frame, bd=2)
        self.text_frame.place(x=0, y=80, height=450, width=585)

        scroll_bar = Scrollbar(self.text_frame)
        scroll_bar.pack(side=RIGHT, fill=Y)

        self.textbox = Text(self.text_frame,
                            height=440,
                            font='Calibri',
                            yscrollcommand=scroll_bar.set)
        self.textbox.pack(fill=Y)
        self.textbox.config(state='disabled')
        scroll_bar.config(command=self.textbox.yview)

        self.btn_frame = Frame(self.main_frame, bd=2, bg='#BCF8EA')
        self.btn_frame.place(x=0, y=530, height=40, width=585)

        self.clear_btn = Button(self.btn_frame,
                                text='Clear',
                                command=lambda: self.textbox.delete(0.0, END))
        self.clear_btn.grid(row=0, column=0, ipadx=5, padx=5, sticky='nesw')
        self.clear_btn.config(state='disabled')

        self.attach_btn = Button(self.btn_frame,
                                 text='Attach',
                                 command=self.add_attach)
        self.attach_btn.grid(row=0, column=2, ipadx=5, padx=5, sticky='nesw')
        self.attach_btn.config(state='disabled')

        self.login_btn = Button(self.btn_frame,
                                text='Login',
                                command=self.log_in)
        self.login_btn.grid(row=0, column=3, ipadx=5, padx=5, sticky='nesw')

        self.send_btn = Button(self.btn_frame,
                               text='Send',
                               command=self.send_mail)
        self.send_btn.grid(row=0, column=4, ipadx=5, padx=5, sticky='nesw')
        self.send_btn.config(state='disabled')
Exemplo n.º 30
0
    def __init__(self, wn):
        self.xe = 400
        self.ye = 15

        self.wind = wn
        self.wind.title("Aplicacion de Inventario")
        self.wind.resizable(width=0, height=0)
        self.wind.geometry("802x500")
        self.wind.iconbitmap('archivo.ico')

        self.tree = ttk.Treeview(wn)
        self.tree['columns'] = ("ID", "PRECIO_COSTO", "PRECIO_VENTA",
                                "CANTIDAD")
        self.tree.place(x=0, y=200)
        self.tree.bind("<Double-Button-1>", self.seleccionar_click)
        self.tree.column('#0', width=0, stretch=NO)
        self.tree.column('#1', minwidth=200, anchor=CENTER)
        self.tree.column('#2', minwidth=200, anchor=CENTER)
        self.tree.column('#3', minwidth=200, anchor=CENTER)
        self.tree.column('#4', minwidth=200, anchor=CENTER)
        self.tree.heading('#1', text='ID', anchor=CENTER)
        self.tree.heading('#2', text='PRECIO COSTO', anchor=CENTER)
        self.tree.heading('#3', text='PRECIO VENTA', anchor=CENTER)
        self.tree.heading('#4', text='CANTIDAD', anchor=CENTER)
        self.obt_productos()

        self.l1 = Label(self.wind, text="Agregue un producto")
        self.l1.place(x=(self.xe - 55), y=self.ye)

        self.lid = Label(self.wind, text="ID: ")
        self.lid.place(x=356, y=40)
        self.id = Entry(self.wind, width=30)
        self.id.focus()
        self.id.place(x=self.xe, y=(self.ye + 25))

        self.lprice_c = Label(self.wind, text="Precio Costo: ")
        self.lprice_c.place(x=300, y=70)
        self.price_c = Entry(self.wind, width=30)
        self.price_c.place(x=self.xe, y=(self.ye + 55))

        self.lprice_v = Label(self.wind, text="Precio Venta: ")
        self.lprice_v.place(x=300, y=100)
        self.price_v = Entry(self.wind, width=30)
        self.price_v.place(x=self.xe, y=(self.ye + 85))

        self.lamount = Label(self.wind, text="Cantidad: ")
        self.lamount.place(x=318, y=130)
        self.amount = Entry(self.wind, width=30)
        self.amount.place(x=self.xe, y=(self.ye + 115))

        self.b1 = ttk.Button(self.wind,
                             text="Guardar producto",
                             width=60,
                             command=self.agregar_producto)
        self.b1.place(x=(self.xe - 185), y=(self.ye + 145))

        self.b2 = ttk.Button(self.wind,
                             text="Eliminar Producto",
                             width=60,
                             command=self.eliminar_producto)
        self.b2.place(x=(self.xe), y=(self.ye + 435))
        self.b2['state'] = 'disable'

        self.b3 = ttk.Button(self.wind,
                             text="Actualizar Producto",
                             width=60,
                             command=self.editar_producto)
        self.b3.place(x=30, y=(self.ye + 435))
        self.b3['state'] = 'disable'

        self.img = PhotoImage(file='lupa.png')
        self.bsearch = Button(self.wind,
                              width=35,
                              height=35,
                              command=self.windbuscar)
        self.bsearch.config(image=self.img)
        self.bsearch.place(x=15, y=15)
        Hovertip(self.bsearch, text="Buscar", hover_delay=100)

        self.img1 = PhotoImage(file='clientes.png')
        self.bclientes = Button(self.wind,
                                width=35,
                                height=35,
                                command=self.windclientes)
        self.bclientes.config(image=self.img1)
        self.bclientes.place(x=15, y=65)
        Hovertip(self.bclientes, text="Clientes", hover_delay=100)

        "Acabo de agregar el boton MAS"
        self.img2 = PhotoImage(file='mas.png')
        self.bmas = Button(self.wind,
                           width=15,
                           height=15,
                           command=self.suma_inventario)
        self.bmas.config(image=self.img2)
        self.bmas.place(x=590, y=130)

        "Acabo de agregar el boton MENOS"
        self.img3 = PhotoImage(file='menos.png')
        self.bmenos = Button(self.wind,
                             width=15,
                             height=15,
                             command=self.resta_inventario)
        self.bmenos.config(image=self.img3)
        self.bmenos.place(x=615, y=130)

        "Acabo de agregar el boton actualizar"
        self.img4 = PhotoImage(file='actualizar.png')
        self.bactualizar = Button(self.wind,
                                  width=18,
                                  height=18,
                                  command=self.obt_productos)
        self.bactualizar.configure(image=self.img4)
        self.bactualizar.place(x=590, y=160)

        "Agrege el boton de pedido"
        self.img5 = PhotoImage(file='pedido.png')
        self.bpedido = Button(self.wind,
                              width=35,
                              height=35,
                              command=self.windpedido1)
        self.bpedido.configure(image=self.img5)
        self.bpedido.place(x=15, y=115)
        Hovertip(self.bpedido, text="PEDIDOS")

        self.menuvar = Menu(self.wind)
        self.menuDB = Menu(self.menuvar, tearoff=0)
        self.menuDB.add_command(label="Limpiar Base De Datos 'PRODUCTO'",
                                command=self.borrarDB)
        self.menuvar.add_cascade(label="Inicio", menu=self.menuDB)

        self.ayudamenu = Menu(self.menuvar, tearoff=0)
        self.ayudamenu.add_command(label="Resetear Campos", command=self.clean)
        self.ayudamenu.add_command(
            label="Manual de Usuario")  # command = self.manual_usuario)
        self.menuvar.add_cascade(label="Ayuda", menu=self.ayudamenu)

        self.wind.config(menu=self.menuvar)