Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Option to use ttk elements for NavigationToolbar Tk backend #28607

Open
@smp55

Description

@smp55

Problem

NavigationToolbar2Tk uses standard Tk buttons which can be a bit janky looking, especially if you're using ttk elements elsewhere in your GUI. Having an option to use ttk elements in the toolbar would make for a more consistent look throughout such an application.

Proposed solution

I've found this to work pretty well, although I've only tested it in the most basic case. Not sure about DPI rescaling, etc.

class NavigationToolbar2Ttk(NavigationToolbar2Tk):    def _Button(self, text, image_file, toggle, command):        im = tk.PhotoImage(master=self, file=image_file)        b = ttk.Button(self, text=text, padding=(2, 2), image=im, command=command)        b._ntimage = im        b.pack(side='left')        return b    def _Spacer(self):        s = ttk.Separator(master=self, orient='vertical')        s.pack(side='left', padx='3p', pady='5p', fill='y')        return s    def _update_buttons_checked(self):        for text in ['Zoom', 'Pan']:            if text in self._buttons:                if self.mode.name == text.upper():                    self._buttons[text].state(['pressed'])                else:                    self._buttons[text].state(['!pressed'])

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp