Rocksolid Light

Welcome to novaBBS (click a section below)

mail  files  register  newsreader  groups  login

Message-ID:  

Small is beautiful.


devel / comp.lang.python / Re: Flush / update GUIs in PyQt5 during debugging in PyCharm

SubjectAuthor
* Flush / update GUIs in PyQt5 during debugging in PyCharmMohsen Owzar
`* Re: Flush / update GUIs in PyQt5 during debugging in PyCharmDFS
 `- Re: Flush / update GUIs in PyQt5 during debugging in PyCharmMohsen Owzar

1
Flush / update GUIs in PyQt5 during debugging in PyCharm

<ba7e4c09-ec8b-4b2c-bae6-b2295776f2f9n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:a37:f902:: with SMTP id l2mr8426095qkj.511.1632458769393; Thu, 23 Sep 2021 21:46:09 -0700 (PDT)
X-Received: by 2002:a37:2e87:: with SMTP id u129mr8517160qkh.208.1632458769226; Thu, 23 Sep 2021 21:46:09 -0700 (PDT)
Path: i2pn2.org!rocksolid2!news.neodome.net!feeder1.feed.usenet.farm!feed.usenet.farm!tr2.eu1.usenetexpress.com!feeder.usenetexpress.com!tr3.iad1.usenetexpress.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Thu, 23 Sep 2021 21:46:09 -0700 (PDT)
Injection-Info: google-groups.googlegroups.com; posting-host=31.165.67.106; posting-account=BtTavwoAAACMi3AFrA3U-JBERbxGUGhD
NNTP-Posting-Host: 31.165.67.106
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <ba7e4c09-ec8b-4b2c-bae6-b2295776f2f9n@googlegroups.com>
Subject: Flush / update GUIs in PyQt5 during debugging in PyCharm
From: mohsen.o...@gmail.com (Mohsen Owzar)
Injection-Date: Fri, 24 Sep 2021 04:46:09 +0000
Content-Type: text/plain; charset="UTF-8"
Lines: 9
 by: Mohsen Owzar - Fri, 24 Sep 2021 04:46 UTC

Hi Guys
I've written a GUI using PyQt5 and in there I use StyleSheets (css) for the buttons and labels to change their background- and foreground-colors and their states as well.
Because my program doesn't function correctly, I try to debug it in my IDE (PyCharm).
The problem is that during debugging, when I change some attributes of a button or label, let say its background-color, I can not see this modification of the color until the whole method or function is completed.
I believe that I have seen somewhere during my searches and googling that one can flush or update the GUI after each step/action is done.
But until now I couldn't manage it and I don't know where I have to invoke flush/update command in PyCharm.
If anyone has done this before and knows about it, I would very appreciate seeing his solution.

Regards
Mohsen

Re: Flush / update GUIs in PyQt5 during debugging in PyCharm

<iSj3J.118700$Kv2.48255@fx47.iad>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
Path: i2pn2.org!i2pn.org!paganini.bofh.team!news.dns-netz.com!news.freedyn.net!newsreader4.netcologne.de!news.netcologne.de!peer02.ams1!peer.ams1.xlned.com!news.xlned.com!peer03.iad!feed-me.highwinds-media.com!news.highwinds-media.com!fx47.iad.POSTED!not-for-mail
Subject: Re: Flush / update GUIs in PyQt5 during debugging in PyCharm
Newsgroups: comp.lang.python
References: <ba7e4c09-ec8b-4b2c-bae6-b2295776f2f9n@googlegroups.com>
From: nos...@dfs.com (DFS)
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101
Thunderbird/78.14.0
MIME-Version: 1.0
In-Reply-To: <ba7e4c09-ec8b-4b2c-bae6-b2295776f2f9n@googlegroups.com>
Content-Type: text/plain; charset=utf-8; format=flowed
Content-Language: en-US
Content-Transfer-Encoding: 7bit
Lines: 20
Message-ID: <iSj3J.118700$Kv2.48255@fx47.iad>
X-Complaints-To: abuse@blocknews.net
NNTP-Posting-Date: Fri, 24 Sep 2021 12:52:30 UTC
Organization: blocknews - www.blocknews.net
Date: Fri, 24 Sep 2021 08:52:27 -0400
X-Received-Bytes: 1866
 by: DFS - Fri, 24 Sep 2021 12:52 UTC

On 9/24/2021 12:46 AM, Mohsen Owzar wrote:
> Hi Guys
> I've written a GUI using PyQt5 and in there I use StyleSheets (css) for the buttons and labels to change their background- and foreground-colors and their states as well.
> Because my program doesn't function correctly, I try to debug it in my IDE (PyCharm).
> The problem is that during debugging, when I change some attributes of a button or label, let say its background-color, I can not see this modification of the color until the whole method or function is completed.
> I believe that I have seen somewhere during my searches and googling that one can flush or update the GUI after each step/action is done.
> But until now I couldn't manage it and I don't know where I have to invoke flush/update command in PyCharm.
> If anyone has done this before and knows about it, I would very appreciate seeing his solution.
>
> Regards
> Mohsen

screen:
form.repaint()

individual widgets:
form.widget.repaint()

Re: Flush / update GUIs in PyQt5 during debugging in PyCharm

<d1e45f8a-96f2-48b6-88ab-88b89297ccd5n@googlegroups.com>

  copy mid

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

  copy link   Newsgroups: comp.lang.python
X-Received: by 2002:ac8:4291:: with SMTP id o17mr12202799qtl.147.1632625963499;
Sat, 25 Sep 2021 20:12:43 -0700 (PDT)
X-Received: by 2002:a05:6214:1427:: with SMTP id o7mr8567031qvx.45.1632625963344;
Sat, 25 Sep 2021 20:12:43 -0700 (PDT)
Path: i2pn2.org!i2pn.org!weretis.net!feeder6.news.weretis.net!news.misty.com!border2.nntp.dca1.giganews.com!border1.nntp.dca1.giganews.com!nntp.giganews.com!news-out.google.com!nntp.google.com!postnews.google.com!google-groups.googlegroups.com!not-for-mail
Newsgroups: comp.lang.python
Date: Sat, 25 Sep 2021 20:12:43 -0700 (PDT)
In-Reply-To: <iSj3J.118700$Kv2.48255@fx47.iad>
Injection-Info: google-groups.googlegroups.com; posting-host=2001:1711:fa54:36a0:48c7:2343:7caf:7dec;
posting-account=BtTavwoAAACMi3AFrA3U-JBERbxGUGhD
NNTP-Posting-Host: 2001:1711:fa54:36a0:48c7:2343:7caf:7dec
References: <ba7e4c09-ec8b-4b2c-bae6-b2295776f2f9n@googlegroups.com> <iSj3J.118700$Kv2.48255@fx47.iad>
User-Agent: G2/1.0
MIME-Version: 1.0
Message-ID: <d1e45f8a-96f2-48b6-88ab-88b89297ccd5n@googlegroups.com>
Subject: Re: Flush / update GUIs in PyQt5 during debugging in PyCharm
From: mohsen.o...@gmail.com (Mohsen Owzar)
Injection-Date: Sun, 26 Sep 2021 03:12:43 +0000
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable
Lines: 196
 by: Mohsen Owzar - Sun, 26 Sep 2021 03:12 UTC

DFS schrieb am Freitag, 24. September 2021 um 14:52:41 UTC+2:
> On 9/24/2021 12:46 AM, Mohsen Owzar wrote:
> > Hi Guys
> > I've written a GUI using PyQt5 and in there I use StyleSheets (css) for the buttons and labels to change their background- and foreground-colors and their states as well.
> > Because my program doesn't function correctly, I try to debug it in my IDE (PyCharm).
> > The problem is that during debugging, when I change some attributes of a button or label, let say its background-color, I can not see this modification of the color until the whole method or function is completed.
> > I believe that I have seen somewhere during my searches and googling that one can flush or update the GUI after each step/action is done.
> > But until now I couldn't manage it and I don't know where I have to invoke flush/update command in PyCharm.
> > If anyone has done this before and knows about it, I would very appreciate seeing his solution.
> >
> > Regards
> > Mohsen
> screen:
> form.repaint()
>
> individual widgets:
> form.widget.repaint()

@DFS
Hi
I tried to use your suggestion in my code, to see changes in the background-color of the widgets (buttons and labels).
Below is the link of two screenshots of my GUI:
https://imgur.com/a/5LIefN7
They show the start phase and after clicking the “All Active” button.
As I wrote before, I use Stylesheets for configuring widgets.
Here is the code snipped of the relevant part:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
if state == 'All Active':
.. . .
.. . .
for i in range(7):
for j in range(6):
self.buttons_active[j].setText('Inactive')
self.buttons_active[j].setEnabled(True)
self.buttons_active[j].setChecked(True)
self.buttons_active[j].setStyleSheet(css_pushButton())
######################################################

self.buttons_reset[j].setChecked(True)
self.buttons_reset[j].setEnabled(False)
self.buttons_reset[j].setStyleSheet(css_pushButton())

#####################################################

if i > 0 and j < 6:
################################################
self.labels[i, j].setProperty('orange', True)
# self.labels[i, j].repaint()
# aaaa = 4
else:
################################################
self.labels[i, j].setProperty('yellow', True)
# self.labels[i, j].repaint()
# aaaa = 4

self.labels[i, j].setStyleSheet(css_Label())
self.labels[i, j].repaint()
aaa = 4
#####################################################

else:
.. . .
.. . .
for i in range(7):
for j in range(6):
self.buttons_active[j].setText('Active')
self.buttons_active[j].setEnabled(True)
self.buttons_active[j].setStyleSheet(css_pushButton())
######################################################

######################################################
self.buttons_reset[j].setChecked(False)
self.buttons_reset[j].setEnabled(True)
self.buttons_reset[j].setStyleSheet(css_pushButton())
######################################################

if i > 0:
##################################################
self.labels[i, j].setProperty('gray', True)
# self.labels[i, j].repaint()
# aaaa = 4
else:
self.labels[i, j].setProperty('yellow', True)
# self.labels[i, j].repaint()
# aaaa = 4

self.labels[i, j].setStyleSheet(css_Label())
self.labels[i, j].repaint()
aaa = 4
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
As you can see, the if-else part has to change the background-color of the gray labels (at the start) and the buttons “Active”, “Reset”, “All Active” and “Exit” to orange.
The problem is, after clicking on the “All Active” button all “Resets” and the gray labels change their background-color to orange as desired.
But when I afterwards click again on this button (Now its name is “All Inactive”), the “Resets” and “Exit” buttons change their color and not the 36 labels. They remain in orange.
Therefore I wanted to debug the code in PyCharm and used your suggestion, at first with “form.widget.repaint()” and then with “form.repaint()”.
It didn’t help. I put after the repaint() command line a dummy line to set a break point there. I have put the repair() attribute everywhere in the loop to see if it makes any difference. Nothing was changed.
As long as I was in the “for-loop” and the indices “I” and “j” did not have their end value, I couldn’t see any changes at the break point “aaa = 4”.
Do you know why it didn’t update the GUI?
Perhaps it is not possible to see any changes or updates in the debug mode!!

The CSS part is as below:
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
def css_Label():
css = '''
QLabel {background-color: #E0E0E0;
color: black;
border-style: outset;
border-width: 2px;
border-radius: 5px;
border-color: blue;
font: bold 16px;
min-width: 5em;
padding: 4px;
}

QLabel[gray='true'] {background-color: #E0E0E0;
color: black;
border-style: outset;
border-width: 2px;
border-radius: 5px;
border-color: black;
font: bold 16px;
min-width: 5em;
padding: 4px;
}

QLabel[yellow='true'] {color: black;
background-color: yellow;
border-color: black;
font: bold 16px;}

QLabel[orange='true'] {color: black;
background-color: orange;
border-color: black;
font: bold 16px;}

'''
return css

def css_pushButton():
css = '''
QPushButton {
background-color: cyan;
border-style: outset;
border-width: 2px;
border-radius: 5px;
border-color: black;
font: bold 16px;
min-width: 5em;
padding: 4px;
}

QPushButton:disabled {color: blue;
background-color: orange;
font: bold 16px;}

QPushButton:hover {color: black;
background-color: lightgreen;}

QPushButton:hover:enabled {color: blue;
background-color: magenta;}

QPushButton:enabled {background-color: cyan;}

QPushButton:checked {background-color: '#00FF00';
color: red;
font: bold 16px;}
'''
return css
::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::
Regards
Mohsen

1
server_pubkey.txt

rocksolid light 0.9.8
clearnet tor