Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #54303
| From | Rotwang <sg552@hotmail.co.uk> |
|---|---|
| Newsgroups | comp.lang.python |
| Subject | Re: Weird ttk behaviour |
| Date | 2013-09-17 15:25 +0100 |
| Organization | A noiseless patient Spider |
| Message-ID | <l19op8$dse$1@dont-email.me> (permalink) |
| References | <l17bj9$1qs$1@dont-email.me> <mailman.39.1379370869.18130.python-list@python.org> <l19ebk$g94$1@dont-email.me> <mailman.59.1379417584.18130.python-list@python.org> |
On 17/09/2013 12:32, Chris Angelico wrote:
> [...]
>
> If reloading and doing it again makes things different, what happens
> if you simply trigger your code twice without reloading?
>
> I've no idea if it'll help, it just seems like an attack vector on the
> problem, so to speak.
Thanks for the suggestion, here's what I've found with some more
testing. If I rewrite the function f() like this:
def f(fail):
style = ttk.Style(_root)
style.theme_create('newtheme', parent = 'default')
tk.messagebox.showwarning('test', 'test')
if fail:
style.theme_use('newtheme')
tk.messagebox.showwarning('test', 'test')
then I import the module and call f(False) followed by f(True), the
second call raises an exception just like the original function. I've
tried variations of the above, such as defining a module-level global
style instead of having one created during the function call, and the
end result is always the same. However, suppose instead I define two
modules, tkderp and tkderp2; both have a function f as defined in my OP,
but the first has the last two lines of f commented out, and the second
doesn't (i.e. tkderp is the modified tkderp from before, and tkderp2 is
the original). Then I do this:
>>> import tkderp
>>> tkderp.f()
>>> import tkderp2
>>> tkderp2.f()
In that case the second call to f() works fine - two warnings, no
exception. In fact, if I replace tkderp with this:
# begin tkderp.py
import tkinter as tk
_root = tk.Tk()
_root.withdraw()
# end tkderp.py
then simply importing tkderp before tkderp2 is enough to make the latter
work properly - this
>>> import tkderp2
>>> tkderp2.f()
raises an exception, but this
>>> import tkderp
>>> import tkderp2
>>> tkderp2.f()
doesn't. Any ideas what may be going on?
Back to comp.lang.python | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Weird ttk behaviour Rotwang <sg552@hotmail.co.uk> - 2013-09-16 17:28 +0100
Re: Weird ttk behaviour Serhiy Storchaka <storchaka@gmail.com> - 2013-09-16 21:43 +0300
Re: Weird ttk behaviour Rotwang <sg552@hotmail.co.uk> - 2013-09-17 12:15 +0100
Re: Weird ttk behaviour Chris Angelico <rosuav@gmail.com> - 2013-09-17 08:34 +1000
Re: Weird ttk behaviour Rotwang <sg552@hotmail.co.uk> - 2013-09-17 12:27 +0100
Re: Weird ttk behaviour Chris Angelico <rosuav@gmail.com> - 2013-09-17 21:32 +1000
Re: Weird ttk behaviour Rotwang <sg552@hotmail.co.uk> - 2013-09-17 15:25 +0100
Re: Weird ttk behaviour Chris Angelico <rosuav@gmail.com> - 2013-09-18 00:35 +1000
Re: Weird ttk behaviour Rotwang <sg552@hotmail.co.uk> - 2013-09-17 17:11 +0100
Re: Weird ttk behaviour Chris Angelico <rosuav@gmail.com> - 2013-09-18 02:20 +1000
csiph-web