Frage

Python 2.7 (32-Bit) Windows: Wir experimentieren mit Python 2.7 Unterstützung für thematische Tkinter (ttk) für einfache GUI und sind gekommen, weg sehr beeindruckt !! Der einzige Bereich, in dem die neue Theme-Unterstützung zu haben scheint zu kurz kommt ist, wie OS-spezifische gemeinsame Dialoge gewickelt.

Korrigiert: Mit anderen Worten, die MessageBox und ColorChooser gemeinsame Dialoge haben „hässlich“ 95 Stil Win suchen blocky suchen Tasten gegen die Themen (gerundet / Gradient) Tasten, die normalerweise auf diesen gemeinsamen Dialogen zeigen unter XP, Vista und Windows 7. (ich teste auf allen drei Plattformen mit identischen, nicht-themed Ergebnisse).

. Hinweis: Die Dateidialog gemeinsame Dialoge (askopenfilename, askopenfilenames, asksaveasfilename, askdirectory) sind alle richtig Motto

import tkMessageBox as messagebox
messagebox.showinfo()

import tkColorChooser as colorchooser
color = colorchooser.askcolor( parent=root, title='Customize colors' )

Irgendwelche Ideen auf, was erforderlich ist Tkinter des MessageBox und ColorChooser gemeinsam zu bekommen Dialoge OS Thema kompatibel zu sein (zumindest unter Windows XP oder höher)?

War es hilfreich?

Lösung

Your observation is mainly correct. I do see what you are referring to in the messagebox and the colorchooser. However, my filedialogs all seem to have properly rounded buttons, etc.

My recommendation for you on making the messagebox is to create your own messagebox using the TopLevel widget, and then define what you need on it and the appropriate behavior for the different buttons (it's definitely a bit harder than just using a messagebox, but if you really need the new style buttons, it'll work).

I don't think you can hack together a solution for the colorchooser problem, however.

I though for a minute that perhaps Python 3.1 had fixed this problem, but sadly, I tried and that isn't the case. I suppose if you need the user to pick a color, the buttons will have to be ugly.

Andere Tipps

An option to get better looking dialog boxes is to compile your script to an executable using pyinstaller. I explain this more thouroughly here.

tl;dr, it appears that compiling with pyinstaller allows you to have dialog boxes with the style of the currently running OS, but not custom styles.

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top