Ich schick noch einen code-Ausschnitt hinterher, obwohl das m.E. nach nix bringt;
Denn es könnte JEDES Script sein, das ein (neues) Fenster öffnet...
Das klappt ja alles im code - lästig ist eben nur, dass ich dann "händisch" in das erzeugte Fenster clicken muss
Na, vielleicht fällt jemandem was dazu ein?!
Hab zwischendurch (nochmal) alle Attribute zu "TkInter" und "TkInter.commondialog"
und "TkInter.PanedWindows" durchforstet - und natürlich (noch) nicht alle zig hundert Attribute
getestet ( wie z.B. BROWSE.BaseWidget, CURRENT, oder PanedWindow.winfo_name, -parent, pathname
oder "PanedWindow.winfo_screen(self) = "Screen-Name of this widget" oder
"PanedWindow.winfo_toplevel(self)"
Hattet Ihr damit schon mal etwas probiert?
[codebox=python file=e_gold.pyw]
(die Idee ist "geklaut" aus irgend einem Forumsbeitrag - vlt. sogar hier!?)
import tkinter as tk
import gui
OPTIONS = ["Euro -> Gold", "Gold -> Euro"]
UMRECHNUNG_EURO_GOLD = 35.1613
class Application(tk.Tk):
def __init__(self, **kwargs):
tk.Tk.__init__(self, **kwargs)
gui.init_app(self)
# tk.focus_set(self) # -> module 'tkinter' has no attribute 'focus_set'
self.button_2.configure(command=self.destroy)
self.bind(sequence='<Return>', func=self.bt_action)
self.bind(sequence='<Escape>', func=self.bt_ende)
self.option = tk.StringVar(self)
self.option.set(OPTIONS[1])
optionen = tk.OptionMenu(self, self.option, *OPTIONS)
optionen.grid(row = 3, column = 0, pady = 5)
self.entry_3.focus()
def bt_ende(self, event):
self.quit()
def bt_action(self, event):
if self.entry_3.get() == '':
betrag=1
print('1 eingefügt. Nochmal MIT Wert !')
self.label_5.configure(text='Wert vergessen!')
else:
betrag = float(self.entry_3.get())
self.label_5.configure(text='')
wahl = self.option.get()
if wahl == OPTIONS[0]:
betrag /= UMRECHNUNG_EURO_GOLD
einheit= "Gramm"
elif wahl == OPTIONS[1]:
betrag *= UMRECHNUNG_EURO_GOLD
einheit = "Euro"
message = "{:.2f} {}".format(betrag, einheit)
self.label_3.configure(text=message)
# Application().focus_set()
if __name__ == '__main__':
Application().mainloop()
[/code]