Exemplo n.º 1
0
    def _render_box(self, component, gc, view_bounds=None, mode='normal'):
        # draw the arrow if necessary
        if self.arrow_visible:
            if self._cached_arrow is None:
                if self.arrow_root in self._root_positions:
                    ox, oy = self._root_positions[self.arrow_root]
                else:
                    if self.arrow_root == "auto":
                        arrow_root = self.label_position
                    else:
                        arrow_root = self.arrow_root
                    pos = self._position_root_map.get(arrow_root, "DUMMY")
                    ox, oy = self._root_positions.get(pos,
                                        (self.x + self.width / 2,
                                         self.y + self.height / 2))

                if type(ox) == str:
                    ox = getattr(self, ox)
                    oy = getattr(self, oy)
                self._cached_arrow = draw_arrow(gc, (ox, oy),
                                            self._screen_coords,
                                            self.arrow_color_,
                                            arrowhead_size=self.arrow_size,
                                            offset1=3,
                                            offset2=self.marker_size + 3,
                                            minlen=self.arrow_min_length,
                                            maxlen=self.arrow_max_length)
            else:
                draw_arrow(gc, None, None, self.arrow_color_,
                           arrow=self._cached_arrow,
                           minlen=self.arrow_min_length,
                           maxlen=self.arrow_max_length)

        # layout and render the label itself
        ToolTip.overlay(self, component, gc, view_bounds, mode)
Exemplo n.º 2
0
    def overlay(self, component, gc, view_bounds=None, mode="normal"):
        """ Draws the tooltip overlaid on another component.

        Overrides and extends ToolTip.overlay()
        """
        if self.clip_to_plot:
            gc.save_state()
            c = component
            gc.clip_to_rect(c.x, c.y, c.width, c.height)

        self.do_layout()

        # draw the arrow if necessary
        if self.arrow_visible:
            if self._cached_arrow is None:
                if self.arrow_root in self._root_positions:
                    ox, oy = self._root_positions[self.arrow_root]
                else:
                    if self.arrow_root == "auto":
                        arrow_root = self.label_position
                    else:
                        arrow_root = self.arrow_root
                    ox, oy = self._root_positions.get(
                        self._position_root_map.get(arrow_root, "DUMMY"),
                        (self.x + self.width / 2, self.y + self.height / 2))

                if type(ox) == str:
                    ox = getattr(self, ox)
                    oy = getattr(self, oy)
                self._cached_arrow = draw_arrow(gc, (ox, oy),
                                                self._screen_coords,
                                                self.arrow_color_,
                                                arrowhead_size=self.arrow_size,
                                                offset1=3,
                                                offset2=self.marker_size + 3,
                                                minlen=self.arrow_min_length,
                                                maxlen=self.arrow_max_length)
            else:
                draw_arrow(gc,
                           None,
                           None,
                           self.arrow_color_,
                           arrow=self._cached_arrow,
                           minlen=self.arrow_min_length,
                           maxlen=self.arrow_max_length)

        # layout and render the label itself
        ToolTip.overlay(self, component, gc, view_bounds, mode)

        # draw the marker
        if self.marker_visible:
            render_markers(gc, [self._screen_coords], self.marker,
                           self.marker_size, self.marker_color_,
                           self.marker_line_width, self.marker_line_color_,
                           self.custom_symbol)

        if self.clip_to_plot:
            gc.restore_state()
Exemplo n.º 3
0
 def off_vol(self, *arg):
     """Обработка кнопки вкл./выкл. звука"""
     if not self.master.off_volume:
         image=self.img_['soundon']
         ToolTip(self.b['btnvolume'], msg='Звук включен')
     else:
         image=self.img_['soundoff']
         ToolTip(self.b['btnvolume'], msg='Звук выключен')
     self.b['btnvolume'].configure(image=image)
     self.master.off_volume = not self.master.off_volume   
Exemplo n.º 4
0
Arquivo: pui.py Projeto: VVVAlex/bso
 def off_vol(self, *arg):
     """Отключить включить звук"""
     if not self.off_volume:
         image = self.img_['kmix']
         ToolTip(self.b['btnvolume'], msg='Звук включен')
     else:
         image = self.img_['kmixmute']
         ToolTip(self.b['btnvolume'], msg='Звук выключен')
     self.b['btnvolume'].configure(image=image)
     self.off_volume = not self.off_volume
Exemplo n.º 5
0
    def overlay(self, component, gc, view_bounds=None, mode="normal"):
        """ Draws the tooltip overlaid on another component.

        Overrides and extends ToolTip.overlay()
        """
        if self.clip_to_plot:
            gc.save_state()
            c = component
            gc.clip_to_rect(c.x, c.y, c.width, c.height)

        self.do_layout()

        # draw the arrow if necessary
        if self.arrow_visible:
            if self._cached_arrow is None:
                if self.arrow_root in self._root_positions:
                    ox, oy = self._root_positions[self.arrow_root]
                else:
                    if self.arrow_root == "auto":
                        arrow_root = self.label_position
                    else:
                        arrow_root = self.arrow_root
                    ox, oy = self._root_positions.get(
                                 self._position_root_map.get(arrow_root, "DUMMY"),
                                 (self.x+self.width/2, self.y+self.height/2)
                                 )

                if type(ox) == str:
                    ox = getattr(self, ox)
                    oy = getattr(self, oy)
                self._cached_arrow = draw_arrow(gc, (ox, oy), self._screen_coords,
                                                self.arrow_color_,
                                                arrowhead_size=self.arrow_size,
                                                offset1=3,
                                                offset2=self.marker_size+3,
                                                minlen=self.arrow_min_length,
                                                maxlen=self.arrow_max_length)
            else:
                draw_arrow(gc, None, None, self.arrow_color_,
                           arrow=self._cached_arrow,
                           minlen=self.arrow_min_length,
                           maxlen=self.arrow_max_length)

        # layout and render the label itself
        ToolTip.overlay(self, component, gc, view_bounds, mode)

        # draw the marker
        if self.marker_visible:
            render_markers(gc, [self._screen_coords], self.marker, self.marker_size,
                           self.marker_color_, self.marker_line_width,
                           self.marker_line_color_, self.custom_symbol)

        if self.clip_to_plot:
            gc.restore_state()
    def showBagContents(self, bag, frame):
        bag_id = int(bag.get("id"))

        # if no bag is the active bag - this bag becomes the active bag ...
        if self.active_bag_id == -1:
            self.active_bag_id = bag_id

        bag_tag = bag.find("container")
        bag_frame = tk.LabelFrame(frame, text=bag_tag.get("name"))

        if self.active_bag_id == bag_id:
            bag_frame.config(font=config.Style.BAG_LF_FONT, )
            ToolTip(bag_frame, msg.ES_TT_ACTIVE_BAG)
        else:
            ToolTip(bag_frame, msg.ES_TT_INACTIVE_BAG)

        # retrieve bag content and display ...
        item_ids = bag.get("content")

        if item_ids is not None:
            entries = item_ids.split()
            for item_id in entries:
                item = self.char.getItemById(item_id)
                if item is not None:
                    item_line = tk.Frame(bag_frame)
                    quantity_label = tk.Label(item_line,
                                              text=item.get("quantity") +
                                              msg.MULTIPLY)
                    quantity_label.pack(side=tk.LEFT)
                    item_label = tk.Label(item_line, text=item.get("name"))
                    item_label.bind("<Button-1>",
                                    lambda event, id=item_id: self.
                                    displayItemEditor(event, id))
                    item_label.pack(side=tk.LEFT, fill=tk.X, expand=1)
                    unpack_icon = ImageTk.PhotoImage(file="img/unpack.png")
                    item_unpack = tk.Button(item_line, image=unpack_icon)
                    ToolTip(item_unpack, msg.ES_TT_UNPACK)
                    item_unpack.image = unpack_icon
                    item_unpack.bind(
                        "<Button-1>",
                        lambda event, id=item_id: self.unpackItem(event, id))
                    item_unpack.pack(side=tk.RIGHT, anchor=tk.E)
                    item_line.pack(fill=tk.X, expand=1)

        children = bag_frame.winfo_children()
        # for empty bag ...
        if not children:
            tk.Label(bag_frame, text=" ").pack()

        bag_frame.pack(fill=tk.BOTH, expand=1)
        bag_frame.bind(
            "<Button-1>",
            lambda event, bag_id=bag_id: self.setActiveBag(event, bag_id))
Exemplo n.º 7
0
 def hide_hline(self, arg=None):
     """Показать, скрыть гор. линии поля"""
     if self.hide_grid:
         self.board.move_grid(2700, 0)
         image = self.img_['grid2']
         ToolTip(self.b['btnhidevline'], msg='Линии видны')
     else:
         self.board.move_grid(-2700, 0)
         image = self.img_['lauernogrid']
         ToolTip(self.b['btnhidevline'], msg='Линии скрыты')
     self.b['btnhidevline'].configure(image=image)
     self.hide_grid = not self.hide_grid
Exemplo n.º 8
0
 def len_view(self):  #
     """Тригер показ длительности целей"""
     if self.visible_len:
         self.board.show_data_zip(on_eco=True)
         image = self.img_['candlestick']
         ToolTip(self.b['btnlen'], msg='Длительность видна')
     else:
         self.board.canv.delete('point')
         image = self.img_['linechart']
         ToolTip(self.b['btnlen'], msg='Длительность  скрыта')
     self.b['btnlen'].config(image=image)
     self.visible_len = not self.visible_len
     self.board.reconfig()
Exemplo n.º 9
0
 def clr(self):
     """Тригер показ всех точек или одна цель"""
     if self.visible:
         self.board.show_data_zip(on_eco=True)
         image = self.img_['sloion']
         ToolTip(self.b['btnall'], msg='Все эхо')
     else:
         self.board.canv.delete('point')
         image = self.img_['sloi3']
         ToolTip(self.b['btnall'], msg='Одно эхо')
         # self.board.canv.itemconfigure('point_g', fill='black')     # 'green3'
     self.b['btnall'].config(image=image)
     self.visible = not self.visible
     self.board.reconfig()
Exemplo n.º 10
0
 def _bg_img(self) -> ttk.Widget:
     frame = ttk.Frame(self, padding=1)
     frame.rowconfigure(0, weight=1)
     frame.columnconfigure(1, weight=1)
     ttk.Label(frame, text="Background image:").grid(column=0, row=0, sticky="news")
     bgi_text = os.path.basename(self._config.get_str("image_bg"))
     if bgi_text == "":
         bgi_text = "-None-"
     self._set_btn = ttk.Button(frame, text=bgi_text[0:20], command=self._browse_bg_image)
     self._set_btn.grid(column=1, row=0, sticky="news")
     ToolTip(self._set_btn, "Set the scoreboard background image")
     clear_btn = ttk.Button(frame, text="Clear", command=self._clear_bg_image)
     clear_btn.grid(column=2, row=0, sticky="news")
     ToolTip(clear_btn, "Remove the scoreboard background image")
     return frame
Exemplo n.º 11
0
 def hide_metki(self):
     """Показать, скрыть метки"""
     if self.hide_metka:
         self.board.move_metkai_hide(hide=False)
         image = self.img_['geoon']
         ToolTip(self.b['btnmetki'], msg='Метки видны')
         if self.flag_gals:
             self.ch_state((), ('bmman', 'btnmetka'))
     else:
         self.board.move_metkai_hide(hide=True)
         image = self.img_['geooff']
         ToolTip(self.b['btnmetki'], msg='Метки скрыты')
         self.ch_state(('bmman', 'btnmetka'), ())
     self.b['btnmetki'].configure(image=image)
     self.hide_metka = not self.hide_metka
Exemplo n.º 12
0
 def avto_on_off(self, arg=None):
     """Установиь сбросить автомасштаб"""
     if self.viewData:
         self.can_show._scal()
         if not self.avtoscale:
             self.m_avto.set(1)
             self.stbar_avto.set('Масштаб = Авто')
             self.tol_bar.btn['Автомасштаб'].config(image=self.img_['a'])
             ToolTip(self.tol_bar.btn['Автомасштаб'], msg='Автомасштаб')
         else:
             self.m_avto.set(0)
             self.stbar_avto.set('Масштаб = Ручной')
             self.tol_bar.btn['Автомасштаб'].config(image=self.img_['h1'])
             ToolTip(self.tol_bar.btn['Автомасштаб'], msg='Ручной масштаб')
         self.avtoscale = not self.avtoscale
Exemplo n.º 13
0
class PhotoImage(object):

    def __init__(self, photoframe):
        self.window = photoframe.window
        self.photoframe = photoframe
        self.tooltip = ToolTip(self.window)

    def set_photo(self, photo=False):
        if photo is not False:
            self.photo = photo

        width, height = self._get_max_display_size()
        self.pixbuf = PhotoImagePixbuf(self.window, width, height)

        if self.pixbuf.set(self.photo) is False:
            return False

        self._set_tips(self.photo)
        # self.window.resize(1, 1) # FIXME: black magic?
        self._set_photo_image(self.pixbuf.data)
        self.window_border = SETTINGS.get_int('border-width')

        return True

    def on_enter_cb(self, widget, event):
        pass

    def on_leave_cb(self, widget, event):
        pass

    def check_actor(self, stage, event):
        return False

    def check_mouse_on_window(self):
        window, x, y = Gdk.Window.at_pointer() or [None, None, None]
        result = window is self.image.get_window()
        return result

    def has_trash_dialog(self):
        return False

    def _get_max_display_size(self):
        width = SETTINGS_GEOMETRY.get_int('max-width') or 400
        height = SETTINGS_GEOMETRY.get_int('max-height') or 300
        return width, height

    def _set_tips(self, photo):
        self.tooltip.update_photo(photo)
Exemplo n.º 14
0
 def __init__(self, container: tkContainer, config: StarterConfig):
     super().__init__(container, padding=5, text="CTS Start list configuration")
     self._config = config
     self._scb_directory = StringVar(value=self._config.get_str("start_list_dir"))
     self._starter_status = StringVar(value="")
      # self is a vertical container
     self.columnconfigure(0, weight=1)
     # row 0: label
     lbl1 = ttk.Label(self, text="Directory for CTS Start List files:")
     lbl1.grid(column=0, row=0, sticky="ws")
     # row 1: browse button & current directory
     # fr1 is horizontal
     fr1 = ttk.Frame(self)
     fr1.grid(column=0, row=1, sticky="news")
     fr1.rowconfigure(0, weight=1)
     scb_dir_label = ttk.Label(fr1, textvariable=self._scb_directory)
     scb_dir_label.grid(column=1, row=0, sticky="ew")
     btn1 = ttk.Button(fr1, text="Browse", command=self._handle_scb_browse)
     btn1.grid(column=0, row=0)
     ToolTip(btn1, text="Select the directory containing start list files "
             "that have been exported from Meet Manager")   # pylint: disable=C0330
     # row 2: status line
     lbl2 = ttk.Label(self, textvariable=self._starter_status, borderwidth=2,
                      relief="sunken", padding=2)
     lbl2.grid(column=0, row=3, sticky="news")
Exemplo n.º 15
0
 def __init__(self, tooltip=None, **tkArgs):
     Toplevel.__init__(self, tkArgs)
     self.master.withdraw()
     #self.master.geometry("1x1-1-1")
     self.title("Window")
     self.protocol("WM_DELETE_WINDOW", self.destroy)
     self.bind("<Escape>", self.destroy)
     try:
         if sys.platform == "win32":
             iconFile = "icon_win.ico"
         elif sys.platform == "darwin":
             self.config(bg="#EDEDED")
             iconFile = "icon_mac.icns"
         else:  # probably linux
             iconFile = "icon_lin.png"
         iconDir = "%s/python/wikidust/src" % tc_homeDir()
         try:
             self.iconbitmap("%s/%s" % (iconDir, iconFile))
         except:
             pass
     except:  # probably running outside tinkercell
         pass
     if tooltip != None:
         ToolTip(self,
                 text=tooltip,
                 follow_mouse=False,
                 delay=TOOLTIP_DELAY)
     self.focus_force()
Exemplo n.º 16
0
 def __init__(self, container: tkContainer):
     super().__init__(container, padding=5, text="Scoreboard preview")
     canvas = tk.Canvas(self, width=self.WIDTH, height=self.HEIGHT)
     canvas.grid(column=0, row=0, padx=3, pady=3)
     self._canvas = canvas
     self._pimage = None
     ToolTip(self, "Current contents of the scoreboard")
Exemplo n.º 17
0
 def __init__(self, container: tkContainer, watchdir_cb: WatchdirFn,
              config: WahooConfig):
     super().__init__(container,
                      text="CTS Dolphin configuration",
                      padding=5)
     self._config = config
     self._watchdir_cb = watchdir_cb
     self._dolphin_directory = StringVar(
         value=self._config.get_str("dolphin_dir"))
     # self is a vertical container
     self.columnconfigure(0, weight=1)
     # row 0:
     lbl = ttk.Label(self, text="Directory for CTS Dolphin do4 files:")
     lbl.grid(column=0, row=0, sticky="ws")
     # row 1: browse button & current data dir
     # fr2 is horizontal
     fr2 = ttk.Frame(self)
     fr2.rowconfigure(0, weight=1)
     fr2.grid(column=0, row=1, sticky="news")
     btn2 = ttk.Button(fr2, text="Browse", command=self._handle_do4_browse)
     btn2.grid(column=0, row=0)
     ToolTip(
         btn2,
         text="Choose the directory where the Dolphin software "
         "will write race results. The Dolphin software must be configured to use the .do4 format."
     )
     dolphin_dir_label = ttk.Label(fr2,
                                   textvariable=self._dolphin_directory)
     dolphin_dir_label.grid(column=1, row=0, sticky="ew")
Exemplo n.º 18
0
 def showContent(self, frame):
     content_ids = self.item.get("content", "")
     content_ids = content_ids.split(" ")
     content_frame = tk.LabelFrame(frame, text=msg.IE_CONTENT)
     for content_id in content_ids:
         sub_item = self.char.getItemById(content_id)
         if sub_item is not None:
             sub_item_id = sub_item.get("id")
             line = tk.Frame(content_frame)
             label_text = sub_item.get("quantity") + "x - " + sub_item.get("name")
             label = tk.Label(line, text=label_text)
             label.bind(
                 "<Button-1>",
                 lambda event, load_item=sub_item:
                     self.close(load=load_item)
             )
             label.pack(side=tk.LEFT)
             unpack_icon = ImageTk.PhotoImage(file="img/unpack.png")
             unpack_button = tk.Button(line, image=unpack_icon)
             unpack_button.image = unpack_icon
             ToolTip(unpack_button, msg.IE_TT_UNPACK)
             unpack_button.bind(
                 "<Button-1>",
                 lambda event, sub=sub_item, line_widget=line:
                     self.unpackItem(event, sub, line_widget)
             )
             unpack_button.pack(side=tk.RIGHT, anchor=tk.E)
             line.pack(fill=tk.X, expand=1)
     content_frame.pack(fill=tk.X, expand=1)
Exemplo n.º 19
0
    def __init__(self, master, text, imagePath=None, tooltip=None, **opts):
        defaults = {}
        # Used to be {'font': gui.fontButton} but there is no such
        # definition in pyworkflow/gui.
        defaults.update(opts)

        if 'bg' in defaults and defaults['bg'] is None:
            del defaults['bg']

        if imagePath is not None:
            btnImage = gui.getImage(imagePath, Button._images)
        else:
            btnImage = None

        if btnImage is not None:
            if 'compound' not in defaults:
                defaults['compound'] = tk.LEFT
            tk.Button.__init__(self,
                               master,
                               text=text,
                               image=btnImage,
                               **defaults)
            self.image = btnImage
        else:
            tk.Button.__init__(self, master, text=text, **defaults)

        if tooltip:
            from tooltip import ToolTip
            ToolTip(self, tooltip, 500)
Exemplo n.º 20
0
 def grid(self, arg=None):
     """Cкрыть показать сетку"""
     (im, tip) = (self.parent.img_['lauernogrid'], 'Сетка выкл.') if self.GRID \
                  else (self.parent.img_['grid2'], 'Сетка вкл.')
     self.parent.tol_bar.btn['Сетка вкл.'].config(image=im)
     ToolTip(self.parent.tol_bar.btn['Сетка вкл.'], msg=tip)
     self.clr_grid() if self.GRID else self.set_grid()
     self.parent.m_grid.set(1) if self.GRID else self.parent.m_grid.set(0)
Exemplo n.º 21
0
def add_tooltip(text, widgets):
    """Adds a tooltip to multiple elements at once. Useful for setting the
    same tooltip for the label/checkbox and the associated entry/spinbox.
    
    The tooltip widget is also stored at the "tooltip" attribute."""

    for w in widgets:
        w.tooltip = ToolTip(w, text=text)
Exemplo n.º 22
0
 def __init__(self, container: tkContainer,
              scoreboard_run_cb: NoneFn, test_run_cb: NoneFn,
              config: StarterConfig):
     super().__init__(container, padding=5)
     self._config = config
     self._scoreboard_run_cb = scoreboard_run_cb
     self._test_run_cb = test_run_cb
     self.grid(column=0, row=0, sticky="news")
     self.columnconfigure(0, weight=1)
     # Odd rows are empty filler to distribute vertical whitespace
     for i in [1, 3, 5, 7]:
         self.rowconfigure(i, weight=1)
     # row 0: Start list settings
     startlist = _StartList(self, self._config)
     startlist.grid(column=0, row=0, sticky="news")
     # row 2: General settings
     general = _GeneralSettings(self, self._config)
     general.grid(column=0, row=2, sticky="news")
     # row 4: run button(s)
     fr6 = ttk.Frame(self)
     fr6.grid(column=0, row=4, sticky="news")
     fr6.rowconfigure(0, weight=1)
     fr6.columnconfigure(0, weight=0)
     fr6.columnconfigure(1, weight=1)
     test_btn = ttk.Button(fr6, text="Test", command=self._handle_test_btn)
     test_btn.grid(column=0, row=0, sticky="news")
     ToolTip(test_btn, text="Display a mockup to show the current scoreboard style")
     run_btn = ttk.Button(fr6, text="Run Starter", command=self._handle_run_scoreboard_btn)
     run_btn.grid(column=1, row=0, sticky="news")
     ToolTip(run_btn, text="Start the starter simulator")
     # row 6: info panel
     fr8 = ttk.Frame(self)
     fr8.grid(column=0, row=6, sticky="news")
     fr8.rowconfigure(0, weight=1)
     fr8.columnconfigure(0, weight=1)
     fr8.columnconfigure(1, weight=0)
     link_label = ttkwidgets.LinkLabel(fr8,
         text="Documentation: https://swimcam.readthedocs.io/",  # pylint: disable=C0330
         link="https://swimcam.readthedocs.io/?utm_source=swimcam&"  # pylint: disable=C0330
              "utm_medium=config_screen&utm_campaign=docs_link",  # pylint: disable=C0330
         relief="sunken",  # pylint: disable=C0330
         padding=[5, 2])  # pylint: disable=C0330
     link_label.grid(column=0, row=0, sticky="news")
     version_label = ttk.Label(fr8, text=SWIMCAM_VERSION, justify="right",
                               padding=2, relief="sunken")
     version_label.grid(column=1, row=0, sticky="nes")
Exemplo n.º 23
0
 def one_ceil(self, arg=None):
     """Cкрыть показать все цели или одна цель"""
     (im, tip) = (self.parent.img_['sloion'], 'Все цели') if self.flag_on_point \
                  else (self.parent.img_['sloi3'], 'Одна цель')
     self.parent.tol_bar.btn['Все цели'].config(image=im)
     ToolTip(self.parent.tol_bar.btn['Все цели'], msg=tip)
     self.flag_on_point = not self.flag_on_point
     self.update_data()
Exemplo n.º 24
0
 def metka(self, arg=None):
     """Cкрыть показать все метки"""
     (im, tip) = (self.parent.img_['geooff'], 'Показать метки') if self.hide_ \
                  else (self.parent.img_['geoon'], 'Скрыть метки')
     self.parent.tol_bar.btn['Скрыть метки'].config(image=im)
     ToolTip(self.parent.tol_bar.btn['Скрыть метки'], msg=tip)
     self.hide_ = not self.hide_
     self.update_data()
     self.parent.m_hide.set(1) if self.hide_ else self.parent.m_hide.set(0)
Exemplo n.º 25
0
 def __init__(self, container: tkContainer, selection_cb: SelectionFn):
     super().__init__(container, padding=5, text="Chromecast devices")
     cc_chooser = ttk.Treeview(self, selectmode="extended", show="tree")
     cc_chooser.grid(column=0, row=0, sticky="news")
     self._chooser = cc_chooser
     self._selection_cb = selection_cb
     ToolTip(
         self, "Select which Chromecast devices should display the "
         "scoreboard. Use <ctrl> or <shift> to select multiple devices.")
Exemplo n.º 26
0
 def _color_swatch(self, label_text: str, config_item: str, tip_text: str = "") -> ttk.Widget:
     frame = ttk.Frame(self, padding=1)
     frame.rowconfigure(0, weight=1)
     frame.columnconfigure(0, weight=1)
     ttk.Label(frame, text=label_text).grid(column=0, row=0, sticky="news")
     ColorButton(frame, self._config, config_item).grid(column=1, row=0, sticky="news")
     if tip_text != "":
         ToolTip(frame, tip_text)
     return frame
Exemplo n.º 27
0
 def len_view(self, arg=None):
     """Cкрыть показать протяженность цели"""
     (im, tip) = (self.parent.img_['linechart'], 'Длительность  скрыта') if self.flag_on_lentht \
                  else (self.parent.img_['candlestick'], 'Длительность видна')
     self.parent.tol_bar.btn['Длительность видна'].config(image=im)
     ToolTip(self.parent.tol_bar.btn['Длительность видна'], msg=tip)
     self.flag_on_lentht = not self.flag_on_lentht
     self.update_data()
     self.parent.view_len.set(
         1) if self.flag_on_lentht else self.parent.view_len.set(0)
Exemplo n.º 28
0
    def _do_layout(self, size=None):
        """Computes the size and position of the label and arrow.

        Overrides and extends ToolTip._do_layout()
        """
        if not self.component or not hasattr(self.component, "map_screen"):
            return

        # Call the parent class layout.  This computes all the label
        ToolTip._do_layout(self)

        self._screen_coords = self.component.map_screen([self.data_point])[0]
        sx, sy = self._screen_coords

        if isinstance(self.label_position, str):
            orientation = self.label_position
            if ("left" in orientation) or ("right" in orientation):
                if " " not in orientation:
                    self.y = sy - self.height / 2
                if "left" in orientation:
                    self.outer_x = sx - self.outer_width - 1
                elif "right" in orientation:
                    self.outer_x = sx
            if ("top" in orientation) or ("bottom" in orientation):
                if " " not in orientation:
                    self.x = sx - self.width / 2
                if "bottom" in orientation:
                    self.outer_y = sy - self.outer_height - 1
                elif "top" in orientation:
                    self.outer_y = sy
            if "center" in orientation:
                if " " not in orientation:
                    self.x = sx - (self.width/2)
                    self.y = sy - (self.height/2)
                else:
                    self.x = sx - (self.outer_width/2) - 1
                    self.y = sy - (self.outer_height/2) - 1
        else:
            self.x = sx + self.label_position[0]
            self.y = sy + self.label_position[1]

        self._cached_arrow = None
        return
Exemplo n.º 29
0
 def _lane10is0(self) -> ttk.Widget:
     frame = ttk.Frame(self, padding=1)
     frame.rowconfigure(0, weight=1)
     frame.columnconfigure(0, weight=1)
     ttk.Label(frame, text="Lane 10 is 0:").grid(column=0, row=0, sticky="nes")
     self._inhibit_var = BooleanVar(frame, value=self._config.get_bool("lane10iszero"))
     ttk.Checkbutton(frame, variable=self._inhibit_var,
         command=self._handle_inhibit).grid(column=1, row=0, sticky="news") # pylint: disable=C0330
     ToolTip(frame, "Lane 10 is Lane 0 in the pool (Lane #s 0-9)")
     return frame
Exemplo n.º 30
0
    def _do_layout(self, size=None):
        """Computes the size and position of the label and arrow.

        Overrides and extends ToolTip._do_layout()
        """
        if not self.component or not hasattr(self.component, "map_screen"):
            return

        # Call the parent class layout.  This computes all the label
        ToolTip._do_layout(self)

        self._screen_coords = self.component.map_screen([self.data_point])[0]
        sx, sy = self._screen_coords

        if isinstance(self.label_position, str):
            orientation = self.label_position
            if ("left" in orientation) or ("right" in orientation):
                if " " not in orientation:
                    self.y = sy - self.height / 2
                if "left" in orientation:
                    self.outer_x = sx - self.outer_width - 1
                elif "right" in orientation:
                    self.outer_x = sx
            if ("top" in orientation) or ("bottom" in orientation):
                if " " not in orientation:
                    self.x = sx - self.width / 2
                if "bottom" in orientation:
                    self.outer_y = sy - self.outer_height - 1
                elif "top" in orientation:
                    self.outer_y = sy
            if "center" in orientation:
                if " " not in orientation:
                    self.x = sx - (self.width / 2)
                    self.y = sy - (self.height / 2)
                else:
                    self.x = sx - (self.outer_width / 2) - 1
                    self.y = sy - (self.outer_height / 2) - 1
        else:
            self.x = sx + self.label_position[0]
            self.y = sy + self.label_position[1]

        self._cached_arrow = None
        return
Exemplo n.º 31
0
 def _fullscreen(self) -> ttk.Widget:
     frame = ttk.Frame(self, padding=1)
     frame.rowconfigure(0, weight=1)
     frame.columnconfigure(0, weight=1)
     ttk.Label(frame, text="Fullscreen:").grid(column=0, row=0, sticky="nes")
     self._fullscreen_var = BooleanVar(frame, value=self._config.get_bool("fullscreen"))
     ttk.Checkbutton(frame, variable=self._fullscreen_var,
         command=self._handle_fullscreen).grid(column=1, row=0, sticky="news") # pylint: disable=C0330
     ToolTip(frame, "Select to run scoreboard in fullscreen mode; deselect for windowed")
     return frame
Exemplo n.º 32
0
    def _create_tooltip(widget, text):
        tooltip = ToolTip(widget)

        def enter(event):
            tooltip.showtip(text)

        def leave(event):
            tooltip.hidetip()
        widget.bind('<Enter>', enter)
        widget.bind('<Leave>', leave)
Exemplo n.º 33
0
 def __init__(self, container: tkContainer, csv_cb: CSVGenFn,
              config: WahooConfig):
     super().__init__(container,
                      padding=5,
                      text="CTS Start list configuration")
     self._config = config
     self._scb_directory = StringVar(
         value=self._config.get_str("start_list_dir"))
     self._csv_status = StringVar(value="")
     self._csv_cb = csv_cb
     # self is a vertical container
     self.columnconfigure(0, weight=1)
     # row 0: label
     lbl1 = ttk.Label(self, text="Directory for CTS Start List files:")
     lbl1.grid(column=0, row=0, sticky="ws")
     # row 1: browse button & current directory
     # fr1 is horizontal
     fr1 = ttk.Frame(self)
     fr1.grid(column=0, row=1, sticky="news")
     fr1.rowconfigure(0, weight=1)
     scb_dir_label = ttk.Label(fr1, textvariable=self._scb_directory)
     scb_dir_label.grid(column=1, row=0, sticky="ew")
     btn1 = ttk.Button(fr1, text="Browse", command=self._handle_scb_browse)
     btn1.grid(column=0, row=0)
     ToolTip(btn1,
             text="Select the directory containing start list files "
             "that have been exported from Meet Manager")
     # row 2: write csv button
     btn2 = ttk.Button(self,
                       text="Write dolphin_events.csv",
                       command=self._handle_write_csv)
     btn2.grid(column=0, row=2, sticky="ew")
     ToolTip(btn2,
             text="Write a csv file with event information that can "
             "be imported into the Dolphin software")
     # row 3: status line
     lbl2 = ttk.Label(self,
                      textvariable=self._csv_status,
                      borderwidth=2,
                      relief="sunken",
                      padding=2)
     lbl2.grid(column=0, row=3, sticky="news")
Exemplo n.º 34
0
 def __init__(self, photoframe):
     self.window = photoframe.window
     self.photoframe = photoframe
     self.tooltip = ToolTip(self.window)