Rocksolid Light

Welcome to RetroBBS

mail  files  register  newsreader  groups  login

Message-ID:  

lp1 on fire -- One of the more obfuscated kernel messages


devel / comp.lang.python / Tkinter GUI freezing, used Thread then encountered RuntimeError: threads can only be started once

SubjectAuthor
* Tkinter GUI freezing, used Thread then encountered RuntimeError:Abhay Singh
`- Re: Tkinter GUI freezing, used Thread then encountered RuntimeError:MRAB

1
Tkinter GUI freezing, used Thread then encountered RuntimeError: threads can only be started once

<5938bcdd-da2c-41af-81a7-2274e75de5fdn@googlegroups.com>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=25481&group=comp.lang.python#25481

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a0c:e905:0:b0:532:2642:7cdf with SMTP id a5-20020a0ce905000000b0053226427cdfmr794127qvo.63.1673362678550;
Tue, 10 Jan 2023 06:57:58 -0800 (PST)
X-Received: by 2002:a05:6830:22f3:b0:663:bd3a:2e4b with SMTP id
t19-20020a05683022f300b00663bd3a2e4bmr3183171otc.157.1673362678185; Tue, 10
Jan 2023 06:57:58 -0800 (PST)
Path: i2pn2.org!i2pn.org!usenet.blueworldhosting.com!feed1.usenet.blueworldhosting.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Tue, 10 Jan 2023 06:57:57 -0800 (PST)
Injection-Info: google-groups.googlegroups.com; posting-host=203.212.214.96; posting-account=o2o1zAoAAADRO-IbukgGfeEvabz5NQ5U
NNTP-Posting-Host: 203.212.214.96
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <5938bcdd-da2c-41af-81a7-2274e75de5fdn@googlegroups.com>
Subject: Tkinter GUI freezing, used Thread then encountered RuntimeError:
threads can only be started once
From: abskumar798@gmail.com (Abhay Singh)
Injection-Date: Tue, 10 Jan 2023 14:57:58 +0000
Content-Type: text/plain; charset="UTF-8"
X-Received-Bytes: 2351
 by: Abhay Singh - Tue, 10 Jan 2023 14:57 UTC

Here is the entire code snippet of the same.

Please help

def change_flag(top_frame, bottom_frame, button1, button2, button3, button4, controller): global counter, canvas, my_image, chosen, flag, directory canvas.delete('all') button5['state'] = DISABLED counter += 1

chosen, options_text = function_options()
right_answer_flag = get_right_answer_flag(chosen, options_text)
#pdb.set_trace()

try:
location = directory + chosen + format_image
except:
controller.show_frame(PlayAgainExit)

my_image = PhotoImage(file=location)
canvas.create_image(160, 100, anchor=CENTER, image=my_image)

button1["text"] = options_text[0]
button2["text"] = options_text[1]
button3["text"] = options_text[2]
button4["text"] = options_text[3]

button1['state'] = NORMAL
button2['state'] = NORMAL
button3['state'] = NORMAL
button4['state'] = NORMAL
##############

button5 = Button(
next_frame,
width=20,
text="next",
fg="black",
#command=lambda: change_flag(top_frame,bottom_frame,button1,button2,button3,button4,controller))
command=Thread(target=change_flag, args =(top_frame,bottom_frame,button1,button2,button3,button4,controller)).start)

button5.pack(side=RIGHT, padx=5, pady=5)

Thanks,
Abhay

Re: Tkinter GUI freezing, used Thread then encountered RuntimeError: threads can only be started once

<mailman.1461.1673375742.20444.python-list@python.org>

  copy mid

https://www.rocksolidbbs.com/devel/article-flat.php?id=25482&group=comp.lang.python#25482

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!weretis.net!feeder8.news.weretis.net!news.szaf.org!fu-berlin.de!uni-berlin.de!not-for-mail
From: python@mrabarnett.plus.com (MRAB)
Newsgroups: comp.lang.python
Subject: Re: Tkinter GUI freezing, used Thread then encountered RuntimeError:
threads can only be started once
Date: Tue, 10 Jan 2023 18:32:32 +0000
Lines: 54
Message-ID: <mailman.1461.1673375742.20444.python-list@python.org>
References: <5938bcdd-da2c-41af-81a7-2274e75de5fdn@googlegroups.com>
<a09b2276-449e-61f4-1548-ddd9e501ef44@mrabarnett.plus.com>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 7bit
X-Trace: news.uni-berlin.de wtwzOvH6kZmmr5f3sUI4tQoaT329K1w/7X9PxptGfbAQ==
Return-Path: <python@mrabarnett.plus.com>
X-Original-To: python-list@python.org
Delivered-To: python-list@mail.python.org
Authentication-Results: mail.python.org; dkim=pass
reason="2048-bit key; unprotected key"
header.d=plus.com header.i=@plus.com header.b=Aw9AdW+r;
dkim-adsp=none (unprotected policy); dkim-atps=neutral
X-Spam-Status: OK 0.020
X-Spam-Evidence: '*H*': 0.96; '*S*': 0.00; 'def': 0.04; 'gui': 0.05;
'issue.': 0.05; 'thread': 0.05; 'from:addr:python': 0.09;
'received:192.168.1.64': 0.09; 'subject:GUI': 0.09; 'that.': 0.15;
'bugs.': 0.16; 'chosen,': 0.16; 'from:addr:mrabarnett.plus.com':
0.16; 'from:name:mrab': 0.16; 'imho,': 0.16; 'message-
id:@mrabarnett.plus.com': 0.16; 'received:plus.net': 0.16;
'singh': 0.16; 'subject:used': 0.16; 'thread.': 0.16; 'wrote:':
0.16; "can't": 0.17; 'to:addr:python-list': 0.20; 'i.e.': 0.22;
'code': 0.23; 'help.': 0.25; 'function': 0.27; 'header:User-
Agent:1': 0.30; "doesn't": 0.32; 'disabled': 0.32;
'received:192.168.1': 0.32; 'header:In-Reply-To:1': 0.34; 'yes,':
0.35; "skip:' 10": 0.37; 'main': 0.37; 'directory': 0.37;
'received:192.168': 0.37; 'should': 0.40; 'tell': 0.60; 'skip:o
10': 0.61; 'received:212': 0.62; 'here': 0.62; 'skip:b 20': 0.63;
'skip:b 10': 0.63; 'pass': 0.64; 'entire': 0.67; 'skip:# 10':
0.68; 'counter': 0.69; 'global': 0.73; 'skip:c 70': 0.75;
'formatting': 0.76; 'up,': 0.84; '100,': 0.84; 'exceptions': 0.84;
'skip:= 70': 0.84; 'subject:only': 0.84; 'subject:once': 0.91
DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=plus.com; s=042019;
t=1673375553; bh=yqDmqKRaE1m3GeKAJKl11lFxXVQAG0J3aM/xv0W6nyk=;
h=Date:Subject:To:References:From:In-Reply-To;
b=Aw9AdW+ruwWLOE1LFcavldlflmibkVXAw0EqhtC33d67Jf4jLDsJbD8TUPBTTBjBi
mFDDTqFH6LiLQRBiKvTazCzJ75hkhnXNwGn5LxplZdTmv8YbwPeB85tEiy6UVWTKMa
mjo9t1DDmJBoxZ4BtR8pi2lpeh2ABaEdq9JPK2WYaUkrvzGp5XxXUrFHBQv7p7vtye
jEj0M9NOROfZKJNpFbvYXwF5O/yVGjHpV1Y2ZomEZxGjnybKXXVfkktKdcU4TJ858Y
b2BSpSLRVAmHwOhxzv5An/DhoVFhJM2Nuu5swV3KQzn7XLQZUFE3SiT6iZqdm4O9AK
CSbNNH1HrB/mg==
X-Clacks-Overhead: "GNU Terry Pratchett"
X-CM-Score: 0.00
X-CNFS-Analysis: v=2.4 cv=U+qBsMnu c=1 sm=1 tr=0 ts=63bdaf41
a=0nF1XD0wxitMEM03M9B4ZQ==:117 a=0nF1XD0wxitMEM03M9B4ZQ==:17
a=IkcTkHD0fZMA:10 a=fPeC9aqt1o1FjaatSf4A:9 a=QEXdDO2ut3YA:10
X-AUTH: mrabarnett@:2500
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:102.0) Gecko/20100101
Thunderbird/102.6.1
Content-Language: en-GB
In-Reply-To: <5938bcdd-da2c-41af-81a7-2274e75de5fdn@googlegroups.com>
X-CMAE-Envelope: MS4xfKutIIx1jqFbcbQAF5IXj6JBTB/gnzet99m1veQUGW8jP2nA358hyd5MSTwU5oakW8KwpQOjJAxS7FkmB6L5BnidixcXXB6ZszNiKVMX1RMOcAYd++Sb
dyyT9hN2FzU5ae3dnBfe4rQLgDoHaE4DHTeMRlSFNFbjtPiWMZ3nncFU0ZWk9KZyPK//ovSW5dMcgk+08FBRFB03nx01XFbbnx4=
X-BeenThere: python-list@python.org
X-Mailman-Version: 2.1.39
Precedence: list
List-Id: General discussion list for the Python programming language
<python-list.python.org>
List-Unsubscribe: <https://mail.python.org/mailman/options/python-list>,
<mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive: <https://mail.python.org/pipermail/python-list/>
List-Post: <mailto:python-list@python.org>
List-Help: <mailto:python-list-request@python.org?subject=help>
List-Subscribe: <https://mail.python.org/mailman/listinfo/python-list>,
<mailto:python-list-request@python.org?subject=subscribe>
X-Mailman-Original-Message-ID: <a09b2276-449e-61f4-1548-ddd9e501ef44@mrabarnett.plus.com>
X-Mailman-Original-References: <5938bcdd-da2c-41af-81a7-2274e75de5fdn@googlegroups.com>
 by: MRAB - Tue, 10 Jan 2023 18:32 UTC

On 2023-01-10 14:57, Abhay Singh wrote:
> Here is the entire code snippet of the same.
>
> Please help
>
> def change_flag(top_frame, bottom_frame, button1, button2, button3, button4, controller): global counter, canvas, my_image, chosen, flag, directory canvas.delete('all') button5['state'] = DISABLED counter += 1
>
> chosen, options_text = function_options()
> right_answer_flag = get_right_answer_flag(chosen, options_text)
> #pdb.set_trace()
>
> try:
> location = directory + chosen + format_image
> except:
> controller.show_frame(PlayAgainExit)
>
> my_image = PhotoImage(file=location)
> canvas.create_image(160, 100, anchor=CENTER, image=my_image)
>
> button1["text"] = options_text[0]
> button2["text"] = options_text[1]
> button3["text"] = options_text[2]
> button4["text"] = options_text[3]
>
> button1['state'] = NORMAL
> button2['state'] = NORMAL
> button3['state'] = NORMAL
> button4['state'] = NORMAL
> ##############
>
> button5 = Button(
> next_frame,
> width=20,
> text="next",
> fg="black",
> #command=lambda: change_flag(top_frame,bottom_frame,button1,button2,button3,button4,controller))
> command=Thread(target=change_flag, args =(top_frame,bottom_frame,button1,button2,button3,button4,controller)).start)
>
> button5.pack(side=RIGHT, padx=5, pady=5)
>
The formatting is messed up, which doesn't help.

Some points:

You have a 'bare' except, i.e. "except:". Don't do that. It swallows
_all_ exceptions and can hide bugs.

I don't like how you're passing Thread...start as an argument. IMHO, it
would be better/cleaner to pass a plain function, even if the only thing
that function does is to start the thread.

I can't tell what 'change_flag' is doing because of the formatting
issue. Is it doing GUI stuff? In a thread? If yes, don't do that. The
GUI doesn't like that. Only the main thread should do GUI stuff.


devel / comp.lang.python / Tkinter GUI freezing, used Thread then encountered RuntimeError: threads can only be started once

1
server_pubkey.txt

rocksolid light 0.9.81
clearnet tor