Re: How to access Qt components loaded from file?
On Friday, November 21, 2014 2:49:45 AM UTC+5:30, Juan Christian wrote: On Thu Nov 20 2014 at 7:07:10 PM Mark Lawrence wrote: You also need to study the difference between top posting, interspersed posting and bottom posting. The second and third are very much the prefered styles here. Yes I know, but I'm using the new Google Inbox, and I limited to what I can do when replying, to do the right way I have to do many steps now... In gmail 'compose-box' there is a small downward triangle at the right bottom of screen. That allows you to choose plain text mode. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On Thu, 20 Nov 2014 22:41:02 +, Juan Christian wrote: On Thu Nov 20 2014 at 8:20:29 PM alister alister.nospam.w...@ntlworld.com wrote: Then either do the necessary work (you have just proven you can)or find a better way of communicating with this news group(NNTP or the mailing list), otherwise you may find a number of good people simply ignore your posts. While you are at it try to restrict your replies to text only, i see a lot of html garbage at the end of your posts which is also off putting. Which HTML garbage you talking about? All of this VVV div class=gmail_quoteOn Thu Nov 20 2014 at 8:20:29 PM alister lt;a href=mailto:alister.nospam.w...@ntlworld.com;alister.nospam.w...@ntlworld.com/ agt; wrote:blockquote class=gmail_quote style=margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex Then either do the necessary work (you have just proven you can)or find abr better way of communicating with this news group(NNTP or the mailingbr list), otherwise you may find a number of good people simply ignore yourbr posts.br br While you are at it try to restrict your replies to text only, i see abr lot of html garbage at the end of your posts which is also off putting.br/blockquotedivbr/divdivWhich HTML garbage you talking about? /div/div -- Use the Force, Luke. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On Fri Nov 21 2014 at 8:05:30 AM alister alister.nospam.w...@ntlworld.com wrote: All of this VVV [...] I'm sorry, I didn't know, but it seems there isn't any option to remove that in the Inbox (new Gmail), do you guys use any special program or client to use list? -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On Fri, 21 Nov 2014 12:10:21 +, Juan Christian wrote: On Fri Nov 21 2014 at 8:05:30 AM alister alister.nospam.w...@ntlworld.com wrote: All of this VVV [...] I'm sorry, I didn't know, but it seems there isn't any option to remove that in the Inbox (new Gmail), do you guys use any special program or client to use list? div class=gmail_quoteOn Fri Nov 21 2014 at 8:05:30 AM alister lt;a href=mailto:alister.nospam.w...@ntlworld.com;alister.nospam.w...@ntlworld.com/ agt; wrote:brblockquote class=gmail_quote style=margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1exAll of this VVVbr[...]/blockquotedivbr/divdivI#39;m sorry, I didn#39;t know, but it seems there isn#39;t any option to remove that in the Inbox (new Gmail), do you guys use any special program or client to use list? /div/div personally I access the news group via a news server using pan others use the mailing list via their normal email client -- ... Had this been an actual emergency, we would have fled in terror, and you would not have been informed. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
I am in the process of creation of synthesis site looking at other sites, do any of you can aide true value of some books for aggregate roads, aggregate sites, and thank you -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On 21/11/2014 12:10, Juan Christian wrote: On Fri Nov 21 2014 at 8:05:30 AM alister alister.nospam.w...@ntlworld.com mailto:alister.nospam.w...@ntlworld.com wrote: All of this VVV [...] I'm sorry, I didn't know, but it seems there isn't any option to remove that in the Inbox (new Gmail), do you guys use any special program or client to use list? Thunderbird on Windows where I can easily access over 300 Python mailing lists plus a number of blogs, recipes from Activestate and other bits all via gmane or gmene. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On 11/19/2014 07:53 PM, Juan Christian wrote: Thanks, it's working using QTimer. The thing is that whenever the program is going to do something, in my case, draw a new QGroupBox with some components inside and put it in the Form (I'm using VBoxLayout in the main form) the program freezes, and I'm using very simple components just for testing.This shouldn't be normal, right? Am I doing something wrong? Make sure your callbacks always return very quickly. Never do any long task in a GUI event callback. Even your timer event callbacks should return quickly. If you need to do something that takes longer, like load a web page from a url, you need to either do it asynchronously with Qt's API, or spawn a thread to do the heavy lifting. Qt provides a whole bunch of apis for doing this (that overlap python's standard library. For example, instead of urllib2, there's QNetwork (http://pyqt.sourceforge.net/Docs/PyQt4/qtnetwork.html) that provides an asynchronous means of doing sockets, retrieving web content, etc. They aren't very pythonic probably, but they do all emit signals upon completion, so yo don't have to sit in a callback waiting for the download to complete. If you do want to spawn a thread to handle your longer-running task (normal urllib2), you'll have to come up with a way of notifying the main thread that the download is complete; you shouldn't call any GUI calls from the thread, typically. Here's an example of how to have a thread notify the main loop of completion: http://stackoverflow.com/questions/16879971/example-of-the-right-way-to-use-qthread-in-pyqt A quick google can reveal all this information, but it's harder if you don't know what to look for. So I hope this helps. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On 11/19/2014 07:53 PM, Juan Christian wrote: Thanks, it's working using QTimer. The thing is that whenever the program is going to do something, in my case, draw a new QGroupBox with some components inside and put it in the Form (I'm using VBoxLayout in the main form) the program freezes, and I'm using very simple components just for testing.This shouldn't be normal, right? Am I doing something wrong? I clicked send too soon. The stackoverflow link is really referring to another link, which is much more complete and hopefully helpful to you: http://joplaete.wordpress.com/2010/07/21/threading-with-pyqt4/ -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
So, I need to study QThreads, do you know any book or video-course that talks about this matter? I've seen the tutorials that you pointed but I need a wider approach regarding QThreads to really understand it and apply it to my needs. The docs aren't that clear for me. On Thu Nov 20 2014 at 1:43:21 PM Michael Torrie torr...@gmail.com wrote: On 11/19/2014 07:53 PM, Juan Christian wrote: Thanks, it's working using QTimer. The thing is that whenever the program is going to do something, in my case, draw a new QGroupBox with some components inside and put it in the Form (I'm using VBoxLayout in the main form) the program freezes, and I'm using very simple components just for testing.This shouldn't be normal, right? Am I doing something wrong? I clicked send too soon. The stackoverflow link is really referring to another link, which is much more complete and hopefully helpful to you: http://joplaete.wordpress.com/2010/07/21/threading-with-pyqt4/ -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On 11/20/2014 10:57 AM, Juan Christian wrote: So, I need to study QThreads, do you know any book or video-course that talks about this matter? I've seen the tutorials that you pointed but I need a wider approach regarding QThreads to really understand it and apply it to my needs. The docs aren't that clear for me. Yes you should definitely study up on QThreads. What is unclear about the docs? Which docs did you read? Did you read the links I sent you, particularly the wordpress blog post where he had a complete example (although I understand that it's not quite the correct way to do it)? What things have you tried searching for? Google reveals another discussion on stackoverflow which seems to give you a pretty complete, and correct, example: http://stackoverflow.com/questions/16241297/how-to-signal-from-a-running-qthread-back-to-the-pyqt-gui-that-started-it . Note that the first post there is not working, but the fix is listed in the second post. Put them together and you'll have a working example. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
Yes, I read everything and saw that stackoverlfow on Google too. I'm reading this doc: http://pyqt.sourceforge.net/Docs/PyQt4/classes.html I just asked for a book because normally there are books for anything =p On Thu Nov 20 2014 at 5:08:09 PM Michael Torrie torr...@gmail.com wrote: On 11/20/2014 10:57 AM, Juan Christian wrote: So, I need to study QThreads, do you know any book or video-course that talks about this matter? I've seen the tutorials that you pointed but I need a wider approach regarding QThreads to really understand it and apply it to my needs. The docs aren't that clear for me. Yes you should definitely study up on QThreads. What is unclear about the docs? Which docs did you read? Did you read the links I sent you, particularly the wordpress blog post where he had a complete example (although I understand that it's not quite the correct way to do it)? What things have you tried searching for? Google reveals another discussion on stackoverflow which seems to give you a pretty complete, and correct, example: http://stackoverflow.com/questions/16241297/how-to- signal-from-a-running-qthread-back-to-the-pyqt-gui-that-started-it . Note that the first post there is not working, but the fix is listed in the second post. Put them together and you'll have a working example. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
Another problem is that this doc doesn't use Python. On Thu Nov 20 2014 at 5:36:37 PM Juan Christian juan0christ...@gmail.com wrote: Yes, I read everything and saw that stackoverlfow on Google too. I'm reading this doc: http://pyqt.sourceforge.net/Docs/PyQt4/classes.html I just asked for a book because normally there are books for anything =p On Thu Nov 20 2014 at 5:08:09 PM Michael Torrie torr...@gmail.com wrote: On 11/20/2014 10:57 AM, Juan Christian wrote: So, I need to study QThreads, do you know any book or video-course that talks about this matter? I've seen the tutorials that you pointed but I need a wider approach regarding QThreads to really understand it and apply it to my needs. The docs aren't that clear for me. Yes you should definitely study up on QThreads. What is unclear about the docs? Which docs did you read? Did you read the links I sent you, particularly the wordpress blog post where he had a complete example (although I understand that it's not quite the correct way to do it)? What things have you tried searching for? Google reveals another discussion on stackoverflow which seems to give you a pretty complete, and correct, example: http://stackoverflow.com/questions/16241297/how-to-signal- from-a-running-qthread-back-to-the-pyqt-gui-that-started-it . Note that the first post there is not working, but the fix is listed in the second post. Put them together and you'll have a working example. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
**Back to the list So, as I said the PyQt doc is using C o.0 Yes, I read the tutorials, I'll google for some books and things related. On Tue Nov 18 2014 at 10:48:44 AM Vincent Vande Vyvre vincent.vande.vy...@telenet.be wrote: Le 18/11/2014 13:18, Juan Christian a écrit : I have this simple code that load any Qt Designer .UI file: from PySide.QtCore import QFile from PySide.QtGui import QApplication from PySide.QtUiTools import QUiLoader def loadui(file_name): loader = QUiLoader() uifile = QFile(file_name) uifile.open(QFile.ReadOnly) ui = loader.load(uifile) uifile.close() return ui if __name__ == __main__: import sys app = QApplication(sys.argv) MainWindow = loadui(main.ui) MainWindow.show() app.exec_() Let's say I have a QTextEdit called txtbox. How can I access this txtbox inside my Python code? How about MainWindow.txtbox ? -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On 20/11/2014 17:57, Juan Christian wrote: So, I need to study QThreads, do you know any book or video-course that talks about this matter? I've seen the tutorials that you pointed but I need a wider approach regarding QThreads to really understand it and apply it to my needs. The docs aren't that clear for me. You also need to study the difference between top posting, interspersed posting and bottom posting. The second and third are very much the prefered styles here. -- My fellow Pythonistas, ask not what our language can do for you, ask what you can do for our language. Mark Lawrence -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On Thu Nov 20 2014 at 7:07:10 PM Mark Lawrence breamore...@yahoo.co.uk wrote: You also need to study the difference between top posting, interspersed posting and bottom posting. The second and third are very much the prefered styles here. Yes I know, but I'm using the new Google Inbox, and I limited to what I can do when replying, to do the right way I have to do many steps now... -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On Thu, 20 Nov 2014 21:19:28 +, Juan Christian wrote: On Thu Nov 20 2014 at 7:07:10 PM Mark Lawrence breamore...@yahoo.co.uk wrote: You also need to study the difference between top posting, interspersed posting and bottom posting. The second and third are very much the prefered styles here. Yes I know, but I'm using the new Google Inbox, and I limited to what I can do when replying, to do the right way I have to do many steps now... Then either do the necessary work (you have just proven you can)or find a better way of communicating with this news group(NNTP or the mailing list), otherwise you may find a number of good people simply ignore your posts. While you are at it try to restrict your replies to text only, i see a lot of html garbage at the end of your posts which is also off putting. -- There is nothing so easy but that it becomes difficult when you do it reluctantly. -- Publius Terentius Afer (Terence) -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On Thu Nov 20 2014 at 8:20:29 PM alister alister.nospam.w...@ntlworld.com wrote: Then either do the necessary work (you have just proven you can)or find a better way of communicating with this news group(NNTP or the mailing list), otherwise you may find a number of good people simply ignore your posts. While you are at it try to restrict your replies to text only, i see a lot of html garbage at the end of your posts which is also off putting. Which HTML garbage you talking about? -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On Fri, Nov 21, 2014 at 9:41 AM, Juan Christian juan0christ...@gmail.com wrote: On Thu Nov 20 2014 at 8:20:29 PM alister alister.nospam.w...@ntlworld.com wrote: Then either do the necessary work (you have just proven you can)or find a better way of communicating with this news group(NNTP or the mailing list), otherwise you may find a number of good people simply ignore your posts. While you are at it try to restrict your replies to text only, i see a lot of html garbage at the end of your posts which is also off putting. Which HTML garbage you talking about? An extra - and completely superfluous - text/html section in your email. See if you can switch your mailer to use plain text mode. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On 11/20/2014 01:25 PM, Juan Christian wrote: **Back to the list So, as I said the PyQt doc is using C o.0 Yes, I read the tutorials, I'll google for some books and things related. Okay so I took a long look at the example code that was on stackoverflow and figured it out. It's not quite as complete as I thought, and it's only partially functioning. I rewrote it to function a little better. Hopefully it will give you an example. Working with QThread and then moving the worker object to that thread is apparently the recommended way of doing it, but it makes signal handling a two-stage affair. Basically the worker thread has to notify Qthread that it's finished using a finished signal which has to be connected to the QThread's quit() method. That in turn emits its own finished signal which the GUI can trap. It seems a bit convoluted to me. anyway I've attached the working example. import time, sys from PyQt4.QtCore import * from PyQt4.QtGui import * class SimulRunner(QObject): 'Object managing the simulation' stepIncreased = pyqtSignal(int, name = 'stepIncreased') finished = pyqtSignal(name = 'finished') def __init__(self): super(SimulRunner, self).__init__() self._step = 0 self._isRunning = True self._maxSteps = 20 def longRunning(self): self._step = 0 self._isRunning = True while self._step self._maxSteps and self._isRunning == True: self._step += 1 self.stepIncreased.emit(self._step) time.sleep(1) # note since the delay is one second, the thread won't die and the signal # won't be emitted for an entire second. self.finished.emit() def stop(self): print ('stopping.') self._isRunning = False class SimulationUi(QDialog): 'PyQt interface' def thread_finished (self): print ('The thread is finished. You could now do something to update the GUI') def on_stop_button (self): # for some reason we can't have the signal call this directly # but it works from here. Don't know why. self.simulRunner.stop() def __init__(self): super(SimulationUi, self).__init__() self.goButton = QPushButton('Go') self.stopButton = QPushButton('Stop') self.currentStep = QSpinBox() self.layout = QHBoxLayout() self.layout.addWidget(self.goButton) self.layout.addWidget(self.stopButton) self.layout.addWidget(self.currentStep) self.setLayout(self.layout) self.simulRunner = SimulRunner() self.simulThread = QThread() self.simulRunner.moveToThread(self.simulThread) self.simulRunner.stepIncreased.connect(self.currentStep.setValue) self.stopButton.clicked.connect(self.simulRunner.stop) self.goButton.clicked.connect(self.simulThread.start) # As soon as the QThread object starts, instruct it to run our # worker thread's longRunning() method. Can be arbitrarily named self.simulThread.started.connect(self.simulRunner.longRunning) # Here's the tricky part. You must connect a signal from your # thread worker instance that tells the QThread object to # terminate. self.simulRunner.finished.connect(self.simulThread.quit) # now we want to get a signal from the thread so our GUI could # do some update. self.simulThread.finished.connect(self.thread_finished) self.stopButton.clicked.connect(self.on_stop_button) self.goButton.clicked.connect(self.simulThread.start) #self.connect(self.goButton, SIGNAL('clicked()'), self.simulThread.start) self.simulRunner.stepIncreased.connect(self.currentStep.setValue) #self.connect(self.simulRunner,SIGNAL('stepIncreased'), self.currentStep.setValue) if __name__ == '__main__': app = QApplication(sys.argv) simul = SimulationUi() simul.show() sys.exit(app.exec_()) -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On 11/20/2014 08:06 PM, Michael Torrie wrote: anyway I've attached the working example. Just a little caveat. This code is not my original code. I would not do certain things that I just noticed, like these lines: from PyQt4.QtCore import * I would never do that normally, and recommend that you don't either. I might do: import PyQt4.QtCore as QtCore for the sake of brevity while preserving the namespace. Also, while PyQt, being a binding to a C++ library uses camelCase, I would not use it for my own variables and classes. I prefer pep8_compliant_variable_names. Also I note you are using PySide. I believe this example should run with minimal modification to the import statements on PySide -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
Let's say that I want to call the site in a 5min interval. I'm currently getting the info this way just for testing and to know that the 'core engine' is working, and indeed, it's working: if __name__ == __main__: import sys app = QApplication(sys.argv) MainWindow = loadui(main.ui) def output_slot(): MainWindow.txtbox.setText(call_site()) MainWindow.btn.clicked.connect(output_slot) MainWindow.show() app.exec_() How can I proceed if I want the txtbox to automatically do the 'setText(call_site())' in a X defined interval? The final app will have not only a txtbox, but a complete interface with buttons, avatar image, some txtboxes, and all that stuff. If I know how to call the site in a defined interval, I can get all the info that I need and set them one by one. If I'm not mistaken my app is locked in the app.exec_() loop, so I need to have a trigger configured that will be called in a defined interval, then inside this trigger I configure the set_avatar, set_text, set_btn_link, etc, is that right? On Tue Nov 18 2014 at 9:37:21 PM Chris Angelico ros...@gmail.com wrote: On Wed, Nov 19, 2014 at 5:15 AM, Juan Christian juan0christ...@gmail.com wrote: Thanks, it's working. What would be a professional approach if I want to constantly call a URL to get it's content and access this data within the GUI? Constantly doesn't make much sense when you're talking about network operations. There are two basic approaches: either you re-fetch periodically and update the GUI (in which case you have to decide how frequently), or you re-fetch on some trigger (when it's changed, or when the user's about to need it, or something). Either way, you have to balance network traffic versus promptness of update, and it's nearly impossible to pick perfectly. But if you don't mind it being a little clunky, you should be able to pick something fairly simple and deploy it, and then maybe refine it a bit afterward. ChrisA -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On Wed, 19 Nov 2014 20:47:31 + Juan Christian juan0christ...@gmail.com wrote: Let's say that I want to call the site in a 5min interval. I'm currently getting the info this way just for testing and to know that the 'core engine' is working, and indeed, it's working: if __name__ == __main__: import sys app = QApplication(sys.argv) MainWindow = loadui(main.ui) def output_slot(): MainWindow.txtbox.setText(call_site()) MainWindow.btn.clicked.connect(output_slot) MainWindow.show() app.exec_() How can I proceed if I want the txtbox to automatically do the 'setText(call_site())' in a X defined interval? The final app will have not only a txtbox, but a complete interface with buttons, avatar image, some txtboxes, and all that stuff. If I know how to call the site in a defined interval, I can get all the info that I need and set them one by one. If I'm not mistaken my app is locked in the app.exec_() loop, so I need to have a trigger configured that will be called in a defined interval, then inside this trigger I configure the set_avatar, set_text, set_btn_link, etc, is that right? On Tue Nov 18 2014 at 9:37:21 PM Chris Angelico ros...@gmail.com wrote: On Wed, Nov 19, 2014 at 5:15 AM, Juan Christian juan0christ...@gmail.com wrote: Thanks, it's working. What would be a professional approach if I want to constantly call a URL to get it's content and access this data within the GUI? Constantly doesn't make much sense when you're talking about network operations. There are two basic approaches: either you re-fetch periodically and update the GUI (in which case you have to decide how frequently), or you re-fetch on some trigger (when it's changed, or when the user's about to need it, or something). Either way, you have to balance network traffic versus promptness of update, and it's nearly impossible to pick perfectly. But if you don't mind it being a little clunky, you should be able to pick something fairly simple and deploy it, and then maybe refine it a bit afterward. ChrisA -- https://mail.python.org/mailman/listinfo/python-list You'd use a QTimer to do that. Once you .start(5*60*1000) the timer, it'll fire a timeout signal every 5 minutes. You connect that timeout to the slots you want to execute if you don't care about order, or to a single slot function that runs the things that you want to do in some defined order. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
Thanks, it's working using QTimer. The thing is that whenever the program is going to do something, in my case, draw a new QGroupBox with some components inside and put it in the Form (I'm using VBoxLayout in the main form) the program freezes, and I'm using very simple components just for testing.This shouldn't be normal, right? Am I doing something wrong? On Wed Nov 19 2014 at 7:00:43 PM Rob Gaddi rgaddi@technologyhighland.invalid wrote: On Wed, 19 Nov 2014 20:47:31 + Juan Christian juan0christ...@gmail.com wrote: Let's say that I want to call the site in a 5min interval. I'm currently getting the info this way just for testing and to know that the 'core engine' is working, and indeed, it's working: if __name__ == __main__: import sys app = QApplication(sys.argv) MainWindow = loadui(main.ui) def output_slot(): MainWindow.txtbox.setText(call_site()) MainWindow.btn.clicked.connect(output_slot) MainWindow.show() app.exec_() How can I proceed if I want the txtbox to automatically do the 'setText(call_site())' in a X defined interval? The final app will have not only a txtbox, but a complete interface with buttons, avatar image, some txtboxes, and all that stuff. If I know how to call the site in a defined interval, I can get all the info that I need and set them one by one. If I'm not mistaken my app is locked in the app.exec_() loop, so I need to have a trigger configured that will be called in a defined interval, then inside this trigger I configure the set_avatar, set_text, set_btn_link, etc, is that right? On Tue Nov 18 2014 at 9:37:21 PM Chris Angelico ros...@gmail.com wrote: On Wed, Nov 19, 2014 at 5:15 AM, Juan Christian juan0christ...@gmail.com wrote: Thanks, it's working. What would be a professional approach if I want to constantly call a URL to get it's content and access this data within the GUI? Constantly doesn't make much sense when you're talking about network operations. There are two basic approaches: either you re-fetch periodically and update the GUI (in which case you have to decide how frequently), or you re-fetch on some trigger (when it's changed, or when the user's about to need it, or something). Either way, you have to balance network traffic versus promptness of update, and it's nearly impossible to pick perfectly. But if you don't mind it being a little clunky, you should be able to pick something fairly simple and deploy it, and then maybe refine it a bit afterward. ChrisA -- https://mail.python.org/mailman/listinfo/python-list You'd use a QTimer to do that. Once you .start(5*60*1000) the timer, it'll fire a timeout signal every 5 minutes. You connect that timeout to the slots you want to execute if you don't care about order, or to a single slot function that runs the things that you want to do in some defined order. -- Rob Gaddi, Highland Technology -- www.highlandtechnology.com Email address domain is currently out of order. See above to fix. -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
Le 18/11/2014 13:18, Juan Christian a écrit : I have this simple code that load any Qt Designer .UI file: from PySide.QtCore import QFile from PySide.QtGui import QApplication from PySide.QtUiTools import QUiLoader def loadui(file_name): loader = QUiLoader() uifile = QFile(file_name) uifile.open(QFile.ReadOnly) ui = loader.load(uifile) uifile.close() return ui if __name__ == __main__: import sys app = QApplication(sys.argv) MainWindow = loadui(main.ui) MainWindow.show() app.exec_() Let's say I have a QTextEdit called txtbox. How can I access this txtbox inside my Python code? How about MainWindow.txtbox ? -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
Many thanks, worked. The only problem now is that I don't have auto-complete for anything, because of this approach... I'll have to check the doc more regularly. ^^ On Tue Nov 18 2014 at 10:48:44 AM Vincent Vande Vyvre vincent.vande.vy...@telenet.be wrote: Le 18/11/2014 13:18, Juan Christian a écrit : I have this simple code that load any Qt Designer .UI file: from PySide.QtCore import QFile from PySide.QtGui import QApplication from PySide.QtUiTools import QUiLoader def loadui(file_name): loader = QUiLoader() uifile = QFile(file_name) uifile.open(QFile.ReadOnly) ui = loader.load(uifile) uifile.close() return ui if __name__ == __main__: import sys app = QApplication(sys.argv) MainWindow = loadui(main.ui) MainWindow.show() app.exec_() Let's say I have a QTextEdit called txtbox. How can I access this txtbox inside my Python code? How about MainWindow.txtbox ? -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
I was doing some tests, then I tried this: app = QApplication(sys.argv) MainWindow = loadui(main.ui) MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test())) MainWindow.show() app.exec_() But I get RuntimeError: Failed to connect signal clicked()., why? The syntax is correct, I don't know why it failed, the btn is in the Form too, it's a QPushButton. The test func is just a simple func that returns a random text. On Tue Nov 18 2014 at 11:08:48 AM Juan Christian juan0christ...@gmail.com wrote: Many thanks, worked. The only problem now is that I don't have auto-complete for anything, because of this approach... I'll have to check the doc more regularly. ^^ On Tue Nov 18 2014 at 10:48:44 AM Vincent Vande Vyvre vincent.vande.vy...@telenet.be wrote: Le 18/11/2014 13:18, Juan Christian a écrit : I have this simple code that load any Qt Designer .UI file: from PySide.QtCore import QFile from PySide.QtGui import QApplication from PySide.QtUiTools import QUiLoader def loadui(file_name): loader = QUiLoader() uifile = QFile(file_name) uifile.open(QFile.ReadOnly) ui = loader.load(uifile) uifile.close() return ui if __name__ == __main__: import sys app = QApplication(sys.argv) MainWindow = loadui(main.ui) MainWindow.show() app.exec_() Let's say I have a QTextEdit called txtbox. How can I access this txtbox inside my Python code? How about MainWindow.txtbox ? -- https://mail.python.org/mailman/listinfo/python-list -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
Le 18/11/2014 15:49, Juan Christian a écrit : I was doing some tests, then I tried this: app = QApplication(sys.argv) MainWindow = loadui(main.ui) MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test())) MainWindow.show() app.exec_() But I get RuntimeError: Failed to connect signal clicked()., why? The syntax is correct, I don't know why it failed, the btn is in the Form too, it's a QPushButton. The test func is just a simple func that returns a random text. On Tue Nov 18 2014 at 11:08:48 AM Juan Christian juan0christ...@gmail.com mailto:juan0christ...@gmail.com wrote: Many thanks, worked. The only problem now is that I don't have auto-complete for anything, because of this approach... I'll have to check the doc more regularly. ^^ https://mail.python.org/mailman/listinfo/python-list You can't have a slot like this: MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test())) because that's mean: connect to the return of MainWindow.txtbox.setText(test()) and it's not possible at this stage of your program. Use instead a function: MainWindow.btn.clicked.connect(my_slot) # No parenthesis ! def my_slot(): MainWindow.txtbox.setText(test()) -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
You can't have a slot like this: MainWindow.btn.clicked.connect(MainWindow.txtbox.setText(test())) because that's mean: connect to the return of MainWindow.txtbox.setText(test()) and it's not possible at this stage of your program. Use instead a function: MainWindow.btn.clicked.connect(my_slot) # No parenthesis ! def my_slot(): MainWindow.txtbox.setText(test()) Thanks, it's working. What would be a professional approach if I want to constantly call a URL to get it's content and access this data within the GUI? I mean, when I run the program I'm locked in the app.exec_() continuous loop right? So I can't have a loop to get this data from the web, is there any special signal/slot regarding this? -- https://mail.python.org/mailman/listinfo/python-list
Re: How to access Qt components loaded from file?
On Wed, Nov 19, 2014 at 5:15 AM, Juan Christian juan0christ...@gmail.com wrote: Thanks, it's working. What would be a professional approach if I want to constantly call a URL to get it's content and access this data within the GUI? Constantly doesn't make much sense when you're talking about network operations. There are two basic approaches: either you re-fetch periodically and update the GUI (in which case you have to decide how frequently), or you re-fetch on some trigger (when it's changed, or when the user's about to need it, or something). Either way, you have to balance network traffic versus promptness of update, and it's nearly impossible to pick perfectly. But if you don't mind it being a little clunky, you should be able to pick something fairly simple and deploy it, and then maybe refine it a bit afterward. ChrisA -- https://mail.python.org/mailman/listinfo/python-list