I am looking to see if i could get some help and insight on the issue i am having thank you.
I have a program that runs and displays a Tkinter window with a button and a textbox (This works as intended) and the textbox is populated by (self.T.insert(tk.END,"text") and the button calls the class TwitchBot(irc.bot.SingleServerIRCBot).
The first issue i have is that when the class TwitchBot(irc.bot.SingleServerIRCBot) is called the tkinter window freezes.
i think as its a diffrent class, but am unfamillar with tkinter
The second issue is in the class TwitchBot(irc.bot.SingleServerIRCBot) i would still like to populate the textbox with (self.T.insert(tk.END,"text")
i tried to put the code here but it wasnt working well. so uploaded to github
https://github.com/isrever/bot/blob/main/bot.py
Related
spotify example of thumbnail button
I'm trying to implement these thumbnail buttons for my pyqt6 application, however, it looks like pyqt6 has made the QWinThumbnailToolButton class obsolete.
In the changes module: https://doc.qt.io/qt-6/extras-changes-qt6.html, it says that there are explicit replacements, so I've tried looking around the pyqt6 QWindow, and QWidget documentation for any leads but its gotten me nowhere. Does anyone know of a possible solution in PYQT6?
I'm begginer with qt and I have many questions.
One of them is how can I change the centralWidget's content. I have my main.py which is a
QMainWindow and contains my "menu" of my software. When I click on the "Validation" button I want change the centralWidget to show something else like the following exemple :
How would you keep just one QMainWindow and change every time I need the centralWidget ?
I have an application flow which looks like this. At startup a MainWindow is shown and asks the user to choose a project or create a new one. After a project is created or chosen from the list, I want to close this MainWindow and open another MainWindow.
In my main.py the code looks like this:
app = QApplication([])
ui_project_list_view = ProjectListView()
ui_project_list_view.show()
app.exec_()
Now I want to close the first main window (ui_project_list_view) and open the other main window (ui_project_view). This code is called from within ui_project_list_view.
ui_project_view = ProjectView()
ui_project_view.show()
main_view.close()
No matter in which order I show or close, the application quits. How should I design my "window-flow" ?
Thanks for your help.
If you open most programs like Word or Excel- or QtDesigner for example- you'll see a blank main window initialize, and then a popup will appear asking you to choose your project.
If you wanted to apply this to your code, the ProjectView should be the main window and the ProjectListView would be the popup. The ProjectView would call this after initializing, in a setup function perhaps. After ProjectListView finishes, then ProjectView would just need to update the screen with the information that ProjectListView has.
I'm coding a food-ordering app that relies on an expandable listview. When the user selects a quantity from a spinner inside the childview, a button in the groupview should update (from grey to green) to signify the user has picked a quantity in the group.
My problem is refreshing the expandablistview immediately upon the user clicking the spinner. If I use notifydatasetchanged or listview.notifyallviews, this blocks the whole program because the onitemselectedlistener of the spinner is constantly calling the line. Note this doesn't return an error, it's a legitimate program run but the fact of calling notifyallviews after an onitemclicklistener causes the program to be stuck in an endless view update.
I'm not attaching any code because I don't think anythign I wrote will help you. The above description should be giving you all the elements of the problem.
Looking forward to help!
Let me quickly explain the background to this. I'm developing a custom menu system inside a 3D application called Softimage XSI. It has a PyQt application object created already and ProcessEvents is being called a certain number of times every second so that PyQt applications can exist in a non-modal state within XSI.
To implement the menu, I've got a webpage embedded in a toolbar which is calling a plugin for XSI that I've written to show a PyQt menu. This all works fine (albeit, slightly contrived!).
The issue is that when I show the menu, it won't disappear when I click away from it. If I move the mouse over the menu, and then click away from it, it will disappear. It's only when it first pops up.
I've tried everything I can think of. Here's a list:
Using QtGui.qApp.installEventFilter(menu) to try and catch the mousepressed signal. It never gets triggered. I suspect the application itself isn't receiving the click.
Using menu.raise_() makes no difference
Neither does QtGui.qApp.setActiveWindow(menu)
Or menu.setFocus()
I've also tried:
event = QtGui.QMouseEvent(QtCore.QEvent.MouseMove, pos, QtCore.Qt.NoButton, QtCore.Qt.NoButton, QtCore.Qt.NoModifier)
QtGui.qApp.sendEvent(menu, event)
I had a go writing my own QEventLoop, but it just crashed XSI. I suspect trying to run a modal loop inside the other one probably isn't a legal thing to do. Either that, or I really don't know what I'm doing (equally probable)
The only thing I have partial success with is using grabMouse(). This is what makes the menu close if I click away from the menu (only after the mouse has passed over the menu once), but I have to call it a couple of times for it to "stick".
So this is my code at the moment:
class MyMenu (QtGui.QMenu):
def __init__(self, parent = None):
QtGui.QMenu.__init__(self, parent)
self.grabbed=2
def getMouse(self):
if self.grabbed>0:
self.grabMouse()
self.grabbed-=1
def paintEvent(self, event):
QtGui.QMenu.paintEvent(self, event)
self.getMouse()
def hideEvent(self, event):
self.releaseMouse()
def ShowMenu():
menu = MyMenu()
menu.addAction("A")
menu.addAction("B")
menu.addAction("C")
submenu = MyMenu()
submenu.addAction("D")
submenu.addAction("E")
submenu.addAction("F")
menu.addMenu(submenu)
menu.setTearOffEnabled(True)
menu.setStyleSheet("font: 8pt \"Sans Serif\";")
submenu.setStyleSheet("font: 8pt \"Sans Serif\";")
submenu.setTitle("Window")
submenu.setTearOffEnabled(True)
pos = QtGui.QCursor.pos()
pos.setX(105)
menu.popup(pos)
#Prevent garbage collection
QtGui.XSIMenu=menu
QtGui.XSISubMenu=submenu
#Desperate acts!
menu.raise_()
QtGui.qApp.setActiveWindow(menu)
menu.setFocus()
Any thoughts or random suggestions would be very gratefully received as this is driving me nuts! Don't be afraid to suggest modifications to stuff I've already tried, as I'm relatively new to PyQt and I may well have missed something.
Many thanks,
Andy
Just before calling popup with self.trayMenu.popup(QtGui.QCursor.pos()), call self.trayMenu.activateWindow(). Putting activateWindow before popup makes the left-click menu work the same as the right-click menu and it goes away when you click elsewhere. :)