[PyQt] Giving focus to qlineedit after button pressed
Hi I have one keypad having keys 0-9 and one qlineedit . Whenever user press any key it shows in qlineedit . I want that whenever key press the cursor should be visible in the qlineeidt , right now when i press 0-9 from keyboard the cursor remain there and keep blinking and as i click on 0-9 button in application the number added in qlineedit but cursor dont blink anymore . I tried these after pressing button but didnt work self.ui.lineEdit.setFocus(True) self.ui.lineEdit.isActiveWindow() self.ui.lineEdit.raise_() self.ui.lineEdit.setFocus(True) ---> This give me little hope the cursor start blinking but it select all the numbers Any help Thanks ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Pyqt Translation
Hi Detlev , Thanks alot for the reply , Eric IDE is perfect for this . Just in case if anyone else face the problem here is solution . Open Eric IDE , Project and open a new project go to particular folder and open it. After that on the left side it you will find one tab with tooltip of Translation , there you will find the .qm file . After that change the extention of .qm file to .ts file and open it on Qt4 Linguistic (as i tried to open it but Qt4 Linguistic dont open the .qm file) after opening that file select the language and it will ask you for translation . once you have done that than go to File and click on Release As , this will generate the .qm file . Now include your .qm file into the script . Detlev Danke a lot i have been searching for this for long :) Thanks Ahmed On Thu, Jan 31, 2013 at 9:01 PM, Detlev Offenbach wrote: > ** > > Hello, > > > > why not use the eric IDE for development? It has built in interfaces to > the Qt tools and would do the .pro generation in the background for you. It > is really simple to do translation update for just one language, several or > even all, add new languages, ... > > > > Regards, > > Detlev > > > On Thursday 31 January 2013, 18:59:35 uahmed wrote: > > Hi > > Thanks for the reply . I will do same i guess . Can you tell me one thing > how you are making qt project with .py files? > > I installed -qt-creator-py and python-pyside too , but whenever i create a > project it gives me main.cpp file and i didnt find any option in start to > choose python . Sorry i am new to QtCreator . > > Thanks > > Ahmed > > On Thu, Jan 31, 2013 at 3:45 PM, Vincent Vande Vyvre < > vincent.vandevy...@swing.be> wrote: > > Le 31/01/13 13:23, uahmed a écrit : > > > Vincent , Should i make a Qt project and include all the python files > > to it ? In those python files i use Pyqt for updating windows text etc . > > > > On Thu, Jan 31, 2013 at 3:12 PM, uahmed > > <mailto:gleam.uah...@gmail.com>> wrote: > > > > Hi > > > > Thanks for the reply . Is there any way to do tranlsation with > > '.ui' file format or with .py file . I am not using QtCreator i > > did whole code from scratch and i make the other windows in > > QtDesigner which generate the '.ui' file and than i use them in my > > code . > > > > I've never used QtCreator. > > I convert my .ui files to .py, I update the file .pro if necessary and I > run: > > pylupdate4 -noobsolete oqapy.pro > > (oqapy is my app) after that, I open the .ts file with QLinguist. > > > > > -- > > Detlev Offenbach > > det...@die-offenbachs.de > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Pyqt Translation
Hi Thanks for the reply . I will do same i guess . Can you tell me one thing how you are making qt project with .py files? I installed -qt-creator-py and python-pyside too , but whenever i create a project it gives me main.cpp file and i didnt find any option in start to choose python . Sorry i am new to QtCreator . Thanks Ahmed On Thu, Jan 31, 2013 at 3:45 PM, Vincent Vande Vyvre < vincent.vandevy...@swing.be> wrote: > Le 31/01/13 13:23, uahmed a écrit : > > Vincent , Should i make a Qt project and include all the python files > > to it ? In those python files i use Pyqt for updating windows text etc . > > > > On Thu, Jan 31, 2013 at 3:12 PM, uahmed > <mailto:gleam.uah...@gmail.com>> wrote: > > > > Hi > > > > Thanks for the reply . Is there any way to do tranlsation with > > '.ui' file format or with .py file . I am not using QtCreator i > > did whole code from scratch and i make the other windows in > > QtDesigner which generate the '.ui' file and than i use them in my > > code . > > > I've never used QtCreator. > > I convert my .ui files to .py, I update the file .pro if necessary and I > run: > > pylupdate4 -noobsolete oqapy.pro > > (oqapy is my app) after that, I open the .ts file with QLinguist. > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Pyqt Translation
Vincent , Should i make a Qt project and include all the python files to it ? In those python files i use Pyqt for updating windows text etc . On Thu, Jan 31, 2013 at 3:12 PM, uahmed wrote: > Hi > > Thanks for the reply . Is there any way to do tranlsation with '.ui' file > format or with .py file . I am not using QtCreator i did whole code from > scratch and i make the other windows in QtDesigner which generate the '.ui' > file and than i use them in my code . > > Thanks > > > On Thu, Jan 31, 2013 at 2:53 PM, Vincent Vande Vyvre < > vincent.vandevy...@swing.be> wrote: > >> Le 31/01/13 12:37, uahmed a écrit : >> > Hi >> > >> > I am facing problem in doing translation of pyqt application . The way >> > i use to create frame /window is that . I create the frame on Qt4 >> > Designer and it generate the .ui file after that i convert it to >> > python file using pyuic4 tool and include it in the application . >> > >> > I search internet what i get is that qt creator has Languist program >> > that take .pro file format and can generate the language file . What >> > files i can have are the .ui or.py file . and pyqt has pylupdate4 >> > program that can do it but that required .pro file and i have .ui and >> > py file .I also try to open a ui file in qt Creator and save it as a >> > project file and than use pylupdate4 and lupdate but it says its not >> > .pro file format . >> > >> > Can anyone tell me whats the best way to translate the file . In my >> > application sometime i have to update the window text on the runtime >> > so that text is in the code too any way to separate that code ? . I am >> > sorry i am new to converting files for language . >> > >> > Any reply will be the thankful >> > >> > Thank you >> > >> > Ahmed >> > >> > >> > ___ >> > PyQt mailing listPyQt@riverbankcomputing.com >> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt >> This is an example of a file .pro >> >> --- >> SOURCES = main.py\ >> ui_foo.py\ >> ui_dialog.py >> >> TRANSLATIONS= myApp_fr.ts >> >> CODECFORTR = UTF-8 >> >> CODECFORSRC = UTF-8 >> --- >> >> myApp_fr.ts is french in this example, you'll need to create one .ts >> file for each langage. >> >> -- >> Vincent V.V. >> Oqapy <https://launchpad.net/oqapy> . Qarte >> <https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager> >> ___ >> PyQt mailing listPyQt@riverbankcomputing.com >> http://www.riverbankcomputing.com/mailman/listinfo/pyqt >> > > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Pyqt Translation
Hi Thanks for the reply . Is there any way to do tranlsation with '.ui' file format or with .py file . I am not using QtCreator i did whole code from scratch and i make the other windows in QtDesigner which generate the '.ui' file and than i use them in my code . Thanks On Thu, Jan 31, 2013 at 2:53 PM, Vincent Vande Vyvre < vincent.vandevy...@swing.be> wrote: > Le 31/01/13 12:37, uahmed a écrit : > > Hi > > > > I am facing problem in doing translation of pyqt application . The way > > i use to create frame /window is that . I create the frame on Qt4 > > Designer and it generate the .ui file after that i convert it to > > python file using pyuic4 tool and include it in the application . > > > > I search internet what i get is that qt creator has Languist program > > that take .pro file format and can generate the language file . What > > files i can have are the .ui or.py file . and pyqt has pylupdate4 > > program that can do it but that required .pro file and i have .ui and > > py file .I also try to open a ui file in qt Creator and save it as a > > project file and than use pylupdate4 and lupdate but it says its not > > .pro file format . > > > > Can anyone tell me whats the best way to translate the file . In my > > application sometime i have to update the window text on the runtime > > so that text is in the code too any way to separate that code ? . I am > > sorry i am new to converting files for language . > > > > Any reply will be the thankful > > > > Thank you > > > > Ahmed > > > > > > ___ > > PyQt mailing listPyQt@riverbankcomputing.com > > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > This is an example of a file .pro > > --- > SOURCES = main.py\ > ui_foo.py\ > ui_dialog.py > > TRANSLATIONS= myApp_fr.ts > > CODECFORTR = UTF-8 > > CODECFORSRC = UTF-8 > --- > > myApp_fr.ts is french in this example, you'll need to create one .ts > file for each langage. > > -- > Vincent V.V. > Oqapy <https://launchpad.net/oqapy> . Qarte > <https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager> > ___ > PyQt mailing listPyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Pyqt Translation
Hi I am facing problem in doing translation of pyqt application . The way i use to create frame /window is that . I create the frame on Qt4 Designer and it generate the .ui file after that i convert it to python file using pyuic4 tool and include it in the application . I search internet what i get is that qt creator has Languist program that take .pro file format and can generate the language file . What files i can have are the .ui or.py file . and pyqt has pylupdate4 program that can do it but that required .pro file and i have .ui and py file .I also try to open a ui file in qt Creator and save it as a project file and than use pylupdate4 and lupdate but it says its not .pro file format . Can anyone tell me whats the best way to translate the file . In my application sometime i have to update the window text on the runtime so that text is in the code too any way to separate that code ? . I am sorry i am new to converting files for language . Any reply will be the thankful Thank you Ahmed ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Displaying 2nd Window Problem
Thanks a lot . It make it works :) On Fri, Aug 17, 2012 at 4:25 PM, Vincent Vande Vyvre < vincent.vandevy...@swing.be> wrote: > On 16/08/12 22:56, uahmed wrote: > > Hi > > > > I am dealing with 2 windows . One is created by Qt Designer and i > > import it on test.py program . what i did i make a Widget on the test > > program and than add a button to it and on click event I try to popup > > the other window(gui1.py) created by Qt Designer but it never pop ups > > and when i use break and do line by line debugging it shows me this > > message after running this command "myapp2 = MyForm()" on line number > > 35 test.py . > > > > QCoreApplication::exec: The event loop is already running > > > > and once i pressed enter on the terminal it pop up the other window . > > > > I am confuse where i am wrong . > > > > Thanks > > > > Ahmed > > > > > > ___ > > PyQt mailing listPyQt@riverbankcomputing.com > > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > You must keep a reference of your second window. > > self.myapp2 = MyForm() > self.myapp2.show() > > -- > Vincent V.V. > Oqapy <https://launchpad.net/oqapy> . Qarte > <https://launchpad.net/qarte> . PaQager <https://launchpad.net/paqager> > > ___ > PyQt mailing listPyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Displaying 2nd Window Problem
Hi I am dealing with 2 windows . One is created by Qt Designer and i import it on test.py program . what i did i make a Widget on the test program and than add a button to it and on click event I try to popup the other window(gui1.py) created by Qt Designer but it never pop ups and when i use break and do line by line debugging it shows me this message after running this command "myapp2 = MyForm()" on line number 35 test.py . QCoreApplication::exec: The event loop is already running and once i pressed enter on the terminal it pop up the other window . I am confuse where i am wrong . Thanks Ahmed test.py Description: Binary data gui1.py Description: Binary data ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Mouse Hover Event small issue
hi Thanks for the reply thats exactly what i want , i already made a code of more than 1000 lines(chunk of code is in program.py script) and when i try to add your code for mouse over effect its not giving me required result . i saved your script with the name of hover.py from PyQt4 import QtGui, QtCore from PyQt4.QtCore import pyqtSignal import os,sys class HoverButton(QtGui.QToolButton): def enterEvent(self,event): print("Enter") self.setStyleSheet("background-color:#45b545;") def leaveEvent(self,event): self.setStyleSheet("background-color:yellow;") print("Leave") and then i call it from another program and include "hover.py" "program.py" import os,sys from functools import partial from PyQt4 import QtGui, QtCore import hover class main(): def Qbutton(self): buttons["a1"] = QtGui.QToolButton(widget) buttons["a1"].setIconSize(QtCore.QSize(200,200)) buttons["a1"] = hover.HoverButton() app= QtGui.QApplication(sys.argv) sk = main() buttons = {} widget = QtGui.QWidget() sk.Qbutton() widget.show() sys.exit(app.exec_()) Can you please guide me how to add that script to program.py so it works fine .It will really solve my problem .Thanks in advance On Wed, Feb 22, 2012 at 2:08 AM, Hans-Peter Jansen wrote: > On Tuesday 21 February 2012, 03:27:41 uahmed wrote: > > hi , > > > > I want to do hover i saw an example and then write a script which > > will be use as i made program i am facing one problem that hover only > > occur if u putt mouse on the left corner of button i want that it > > will happen for all the button that if i move cursor on button then > > it should change. here is my code > > > > from PyQt4 import QtGui, QtCore > > from PyQt4.QtCore import pyqtSignal > > import os,sys > > > > class HoverButton(QtGui.QToolButton): > > def enterEvent(self,event): > > print("Enter") > > button.setStyleSheet("background-color:#45b545;") > > > > def leaveEvent(self,event): > > button.setStyleSheet("background-color:yellow;") > > print("Leave") > > app = QtGui.QApplication(sys.argv) > > widget = QtGui.QWidget() > > button = QtGui.QToolButton(widget) > > button.setMouseTracking(True) > > buttonss = HoverButton(button) > > button.setIconSize(QtCore.QSize(200,200)) > > widget.show() > > sys.exit(app.exec_()) > > Hi uahmed, > > neither your description nor your code expresses your issue properly. > Here's a simpler version, that might be helpful: > > from PyQt4 import QtGui, QtCore > from PyQt4.QtCore import pyqtSignal > import os,sys > > class HoverButton(QtGui.QToolButton): >def enterEvent(self,event): >print("Enter") >button.setStyleSheet("background-color:#45b545;") > >def leaveEvent(self,event): >button.setStyleSheet("background-color:yellow;") >print("Leave") > > app = QtGui.QApplication(sys.argv) > button = HoverButton() > button.show() > sys.exit(app.exec_()) > > > Pete > ___ > PyQt mailing listPyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Mouse Hover Event small issue
any help ! On Tue, Feb 21, 2012 at 7:27 AM, uahmed wrote: > hi , > > I want to do hover i saw an example and then write a script which will be > use as i made program i am facing one problem that hover only occur if u > putt mouse on the left corner of button i want that it will happen for all > the button that if i move cursor on button then it should change. here is > my code > > from PyQt4 import QtGui, QtCore > from PyQt4.QtCore import pyqtSignal > import os,sys > > class HoverButton(QtGui.QToolButton): > def enterEvent(self,event): > print("Enter") > button.setStyleSheet("background-color:#45b545;") > > def leaveEvent(self,event): > button.setStyleSheet("background-color:yellow;") > print("Leave") > app = QtGui.QApplication(sys.argv) > widget = QtGui.QWidget() > button = QtGui.QToolButton(widget) > button.setMouseTracking(True) > buttonss = HoverButton(button) > button.setIconSize(QtCore.QSize(200,200)) > widget.show() > sys.exit(app.exec_()) > > > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Mouse Hover Event small issue
hi , I want to do hover i saw an example and then write a script which will be use as i made program i am facing one problem that hover only occur if u putt mouse on the left corner of button i want that it will happen for all the button that if i move cursor on button then it should change. here is my code from PyQt4 import QtGui, QtCore from PyQt4.QtCore import pyqtSignal import os,sys class HoverButton(QtGui.QToolButton): def enterEvent(self,event): print("Enter") button.setStyleSheet("background-color:#45b545;") def leaveEvent(self,event): button.setStyleSheet("background-color:yellow;") print("Leave") app = QtGui.QApplication(sys.argv) widget = QtGui.QWidget() button = QtGui.QToolButton(widget) button.setMouseTracking(True) buttonss = HoverButton(button) button.setIconSize(QtCore.QSize(200,200)) widget.show() sys.exit(app.exec_()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Widget image coming on button
Hi I want to putt the background image in my pyqt application . I take a widget and putt image through stylesheet but when i created button the background image use for widget comes on button too . Code: import sys,os from functools import partial from PyQt4 import QtGui, QtCore app = QtGui.QApplication(sys.argv) widget =QtGui.QWidget() screen = QtGui.QDesktopWidget().screenGeometry() widget = QtGui.QWidget() screen_width = screen.width() screen_height = screen.height() widget.resize(screen_width, screen_height) widget.setStyleSheet("border-image:url(Window/default.jpg)") button = QtGui.QPushButton(widget) button.setGeometry(200,500, 130, 130) widget.show() sys.exit(app.exec_()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Importing Css file
Thanks Scott it works for me . just one typo mistake in ur code css = QtCore.QFile(':/my_stylesheet.css') css.open(QtCore.QIODevice.ReadOnly) if css.isOpen(): self.setStyleSheet(QtCore.QVariant(*css*.readAll()).toString()) css.close() Thank you for your help On Thu, Dec 1, 2011 at 1:10 AM, Scott Ballard wrote: > Give this a try, It works for me in my application. I'm able to embed the > css file into the resources file. > > css = QtCore.QFile(':/my_stylesheet.css') > css.open(QtCore.QIODevice.ReadOnly) > if css.isOpen(): > self.setStyleSheet(QtCore.QVariant(qss.readAll()).toString()) > css.close() > > Cheers, > -Scott > > > On Wed, Nov 30, 2011 at 11:14 AM, uahmed wrote: > >> Hi >> >> Now i am getting this error on following code >> >> *Error : Could not parse stylesheet of widget 0x9743b58* >> >> Code : >> >> >> #!/usr/bin/python >> import os ,sys >> from PyQt4.QtCore import * >> from PyQt4.QtGui import * >> file_path = QString("./css_file.css") >> app =QApplication(sys.argv) >> label = QLabel("message") >> label.setStyleSheet(file_path) >> label.show() >> app.exec_() >> >> Css File >> >> QLabel#label { >> color: red; >> padding: 3px; >> } >> #label { >> color: red; >> padding: 3px; >> } >> label { >> color: red; >> padding: 3px; >> } >> .label { >> color: red; >> padding: 3px; >> } >> >> Can anyone please help me in it :( >> >> >> >> On Tue, Nov 29, 2011 at 8:11 PM, uahmed wrote: >> >>> Hi , >>> >>> I want to include a css file to pyqt application , i wrote the following >>> code , but it is not effecting the properties of label >>> >>> my python code is this >>> >>> #!/usr/bin/python >>> import os ,sys >>> from PyQt4.QtCore import * >>> from PyQt4.QtGui import * >>> file_path = QString("css_file.qss") >>> app =QApplication(sys.argv) >>> label =QLabel("message") >>> label.setStyleSheet(file_path) >>> label.show() >>> app.exec_() >>> >>> and "css_file.qss" containing this text >>> >>> .QLabel { >>> font-weight: bold; >>> font-size: 15px; >>> color : green; >>> } >>> >>> >> >> ___ >> PyQt mailing listPyQt@riverbankcomputing.com >> http://www.riverbankcomputing.com/mailman/listinfo/pyqt >> > > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Importing Css file
Hi Now i am getting this error on following code *Error : Could not parse stylesheet of widget 0x9743b58* Code : #!/usr/bin/python import os ,sys from PyQt4.QtCore import * from PyQt4.QtGui import * file_path = QString("./css_file.css") app =QApplication(sys.argv) label = QLabel("message") label.setStyleSheet(file_path) label.show() app.exec_() Css File QLabel#label { color: red; padding: 3px; } #label { color: red; padding: 3px; } label { color: red; padding: 3px; } .label { color: red; padding: 3px; } Can anyone please help me in it :( On Tue, Nov 29, 2011 at 8:11 PM, uahmed wrote: > Hi , > > I want to include a css file to pyqt application , i wrote the following > code , but it is not effecting the properties of label > > my python code is this > > #!/usr/bin/python > import os ,sys > from PyQt4.QtCore import * > from PyQt4.QtGui import * > file_path = QString("css_file.qss") > app =QApplication(sys.argv) > label =QLabel("message") > label.setStyleSheet(file_path) > label.show() > app.exec_() > > and "css_file.qss" containing this text > > .QLabel { > font-weight: bold; > font-size: 15px; > color : green; > } > > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Importing Css file
Hi , I want to include a css file to pyqt application , i wrote the following code , but it is not effecting the properties of label my python code is this #!/usr/bin/python import os ,sys from PyQt4.QtCore import * from PyQt4.QtGui import * file_path = QString("css_file.qss") app =QApplication(sys.argv) label =QLabel("message") label.setStyleSheet(file_path) label.show() app.exec_() and "css_file.qss" containing this text .QLabel { font-weight: bold; font-size: 15px; color : green; } ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Updating Qlabel in widget
hi Thanks for the reply , QLabel will be created once only when count is equal to 2 . Firstly i was thinking same that i make Qlabel first and then recall them and change only text but if i do that then i have to create nearly 40-60 Qlabel to cover all the loop holes so i need to create it on run time to avoid making lots of Qlabels On Thu, Aug 25, 2011 at 3:26 PM, Hans-Peter Jansen wrote: > On Thursday 25 August 2011, 12:02:52 uahmed wrote: > > Hi > > > > I want to update the Qlabel after the widget is made , Problem is > > that updating is base on counter so i call that function after 4 > > seconds , but when it by pass the "if" statment it go through all the > > commands give me no errors but it does not update the widet although > > if i dont putt "if" statment all lines are executed and Qlabel update > > too . Can you please tell me where i am wrong > > > > Here is code > > > > import sys,os > > from functools import partial > > from PyQt4 import QtGui, QtCore > > import time > > > > > > class main(): > > > > def f2(self): > > print "f2" > > global count > > count +=1 > > if ( count == 2): > > msg_label["user"] = > > QtGui.QLabel("update",widget) msg_label["user"].setGeometry(10, 10, > > 100, 100) print count > > QtCore.QTimer.singleShot(4000, self.f2) > > > > > > app = QtGui.QApplication(sys.argv) > > widget = QtGui.QWidget() > > layout = QtGui.QVBoxLayout() > > buttons = {} > > count = 0 > > msg_label = {} > > sk = main() > > sk.f2() > > widget.show() > > sys.exit(app.exec_()) > > Don't recreate the widget over and over again. > > Create it once, and just change the label with setText(). > > Pete > ___ > PyQt mailing listPyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] removeWidget
Hi [Sorry Hans , i clicked on reply all so it Cc to the group too ] Although here i want to destroy the button like i dont want to use it again , if i am not wrong show and hide functions will be use when i want to reuse the button and show and hide will not destroy the button . On Thu, Aug 25, 2011 at 2:58 PM, Hans-Peter Jansen wrote: > [I prefer to not get personal replies on this list] > > On Thursday 25 August 2011, 11:39:46 uahmed wrote: > > Hi > > > > Thanks for the reply , I used .close() . I guess this will destroy > > the widget and will not leave memory for it . > > You cannot close arbitrary widgets, but you can hide and show them > without the need to fiddle with the layouts.. > > Pete > ___ > PyQt mailing listPyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Updating Qlabel in widget
Hi I want to update the Qlabel after the widget is made , Problem is that updating is base on counter so i call that function after 4 seconds , but when it by pass the "if" statment it go through all the commands give me no errors but it does not update the widet although if i dont putt "if" statment all lines are executed and Qlabel update too . Can you please tell me where i am wrong Here is code import sys,os from functools import partial from PyQt4 import QtGui, QtCore import time class main(): def f2(self): print "f2" global count count +=1 if ( count == 2): msg_label["user"] = QtGui.QLabel("update",widget) msg_label["user"].setGeometry(10, 10, 100, 100) print count QtCore.QTimer.singleShot(4000, self.f2) app = QtGui.QApplication(sys.argv) widget = QtGui.QWidget() layout = QtGui.QVBoxLayout() buttons = {} count = 0 msg_label = {} sk = main() sk.f2() widget.show() sys.exit(app.exec_()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] removeWidget
Hi Thanks for the reply , I used .close() . I guess this will destroy the widget and will not leave memory for it . On Thu, Aug 25, 2011 at 2:22 PM, Hans-Peter Jansen wrote: > On Thursday 25 August 2011, 10:43:20 Vincent Vande Vyvre wrote: > > Le 25/08/11 07:59, uahmed a écrit : > > Hi > > > > I want to add widget in (f1) function and want to remove the widget > > from (f2) function . I tried the same thing in same function it do > > work but when i try to remove the widget from another it doesnt . Any > > help ? > > > > Code : > > > > > > import sys,os > > from functools import partial > > from PyQt4 import QtGui, QtCore > > import Skype4Py > > import time > > import socket > > > > > > class main(): > > def f1(self): > > print "f1" > > buttons['user'] = QtGui.QToolButton(widget) > > layout.addWidget(buttons['user']) > > widget.setLayout(layout) > > def f2(self): > > print "f2" > > layout.removeWidget(buttons['user']) > > widget.setLayout(layout) > > > > > > app = QtGui.QApplication(sys.argv) > > widget = QtGui.QWidget() > > layout = QtGui.QVBoxLayout() > > buttons = {} > > sk = main() > > sk.f1() > > sk.f2() > > widget.show() > > sys.exit(app.exec_()) > > > > > > ___ > > PyQt mailing listPyQt@riverbankcomputing.com > > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > > Remove is NOT delete. > > > > Try that: > > > > def f2(self): > > print "f2" > > buttons['user'].deleteLater() > > layout.removeWidget(buttons['user']) > > widget.setLayout(layout) > > Consider using .show() and .hide() > > Pete > ___ > PyQt mailing listPyQt@riverbankcomputing.com > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] removeWidget
Hi I want to add widget in (f1) function and want to remove the widget from (f2) function . I tried the same thing in same function it do work but when i try to remove the widget from another it doesnt . Any help ? Code : import sys,os from functools import partial from PyQt4 import QtGui, QtCore import Skype4Py import time import socket class main(): def f1(self): print "f1" buttons['user'] = QtGui.QToolButton(widget) layout.addWidget(buttons['user']) widget.setLayout(layout) def f2(self): print "f2" layout.removeWidget(buttons['user']) widget.setLayout(layout) app = QtGui.QApplication(sys.argv) widget = QtGui.QWidget() layout = QtGui.QVBoxLayout() buttons = {} sk = main() sk.f1() sk.f2() widget.show() sys.exit(app.exec_()) ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] hover in setStyleSheet
Hi I am generating buttons in the form of loop now i want that i dont use external css file and use the property "setStyleSheet" and do the "hover" . So whenever mouse comes over the button the button color should change ,When i try to putt"hover" in setStyleSheet it dont work , can any body tell me how to do that buttons[text] = QtGui.QToolButton(widget) buttons[text].setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) buttons[text].setIcon(QtGui.QIcon('default.gif')) buttons[text].setIconSize(QtCore.QSize(100,100)) buttons[text].setText(QtCore.QString(full_name)) buttons[text].setStyleSheet("background-color:"+button_colour+";border-radius: 10px;selection-background-color: blue;") What should i add on this line to achieve hover *buttons[text].setStyleSheet("background-color:"+button_colour+";border-radius: 10px;selection-background-color: blue;")* Its a chunk of code and all variables are alive in my code . ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Foreground and Background Color QToolButton
HI I want to change the foreground and bankground color of QToolButton , I know this can be done using ".setStyleSheet " but i want to use other way to do that can it be done through QPlatter i search it on net i do find examples of .setStyleSheet but not through any other way . ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] tkinter after method in pyqt
Thanks alot it works , Here is working example taken from other website . import sys from PyQt4 import QtCore, QtGui class MainWindow(QtGui.QMainWindow): def __init__(self): QtGui.QMainWindow.__init__(self) #QtCore.QTimer.singleShot(4000, self.start) def start(self): print 'start' QtCore.QTimer.singleShot(4000, self.start) if __name__ == "__main__": app = QtGui.QApplication(sys.argv) mw = MainWindow() mw.show() mw.start() sys.exit(app.exec_()) On Wed, Aug 17, 2011 at 12:23 PM, Phil Thompson wrote: > On Wed, 17 Aug 2011 03:07:03 +0500, uahmed wrote: > > Hi > > > > In tkinter i use after method to recall the function after particular > > interval time and that function do the the changes in GUI . What i > should > > use to do changes in Pyqt GUI ? > > QTimer.singleShot() > > Phil > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Text and Image Alignment
Hi Thanks Nick ,It works for me . On Wed, Aug 17, 2011 at 3:02 PM, Nick Gaens wrote: > Try this method: > http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtoolbutton.html#setToolButtonStyle > with one of these values: > http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qt.html#ToolButtonStyle-enum > . > > E.g.: > > yourButton = QtGui.QToolButton() > yourButton.setToolButtonStyle(QtCore.Qt.ToolButtonTextUnderIcon) > yourButton.setText("Some text") > yourButton.setIcon(QtGui.QIcon("./images/someImage.png")) > yourButton.setIconSize(QtCore.QSize(140, 140)) > yourButton.clicked.connect(self.onButtonClicked) > > On Wed, Aug 17, 2011 at 03:39, uahmed wrote: > >> Hi >> >> Thank you for the reply i search for it >> >> >> http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtoolbutton.html >> >> but unfortunately i didnt get any of such method . >> >> On Wed, Aug 17, 2011 at 3:28 AM, Josh Stratton >> wrote: >> >>> QToolbarButton has a value for putting text underneath, which may be >>> more what you want. >>> >>> On Tue, Aug 16, 2011 at 3:20 PM, uahmed wrote: >>> > HI >>> > >>> > I want to do alignment in image and text , i want that image should be >>> on >>> > center top and text should be at the bottom of image . I search for it >>> but >>> > didnt get the relevant search result . Can you please tell me how to >>> do >>> > that ? >>> > >>> > Chunk of Code for Button Without Text: >>> > >>> > button = QtGui.QPushButton(widget) >>> > button.setIcon(QtGui.QIcon('default.gif')) >>> > button.setIconSize(QtCore.QSize(100,100)) >>> > button.setGeometry(xval,yval, 130, 130) >>> > button.connect(button, QtCore.SIGNAL('clicked()'), >>> > partial(calluser, user_Handle)) >>> > >>> > Chunk of Code for Button With Text: >>> > >>> > button = QtGui.QPushButton(widget) >>> > button.setIcon(QtGui.QIcon('default.gif')) >>> > button.setIconSize(QtCore.QSize(100,100)) >>> > button[text].setText(QtCore.QString(user_Handle)) >>> > button.setGeometry(xval,yval, 130, 130) >>> > button.connect(button, QtCore.SIGNAL('clicked()'), >>> > partial(calluser, user_Handle)) >>> > >>> > Thank You >>> > >>> > Ahmed >>> > >>> > ___ >>> > PyQt mailing listPyQt@riverbankcomputing.com >>> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt >>> > >>> >> >> >> ___ >> PyQt mailing listPyQt@riverbankcomputing.com >> http://www.riverbankcomputing.com/mailman/listinfo/pyqt >> > > > > -- > Nick Gaens > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Text and Image Alignment
Hi Thank you for the reply i search for it http://www.riverbankcomputing.co.uk/static/Docs/PyQt4/html/qtoolbutton.html but unfortunately i didnt get any of such method . On Wed, Aug 17, 2011 at 3:28 AM, Josh Stratton wrote: > QToolbarButton has a value for putting text underneath, which may be > more what you want. > > On Tue, Aug 16, 2011 at 3:20 PM, uahmed wrote: > > HI > > > > I want to do alignment in image and text , i want that image should be > on > > center top and text should be at the bottom of image . I search for it > but > > didnt get the relevant search result . Can you please tell me how to do > > that ? > > > > Chunk of Code for Button Without Text: > > > > button = QtGui.QPushButton(widget) > > button.setIcon(QtGui.QIcon('default.gif')) > > button.setIconSize(QtCore.QSize(100,100)) > > button.setGeometry(xval,yval, 130, 130) > > button.connect(button, QtCore.SIGNAL('clicked()'), > > partial(calluser, user_Handle)) > > > > Chunk of Code for Button With Text: > > > > button = QtGui.QPushButton(widget) > > button.setIcon(QtGui.QIcon('default.gif')) > > button.setIconSize(QtCore.QSize(100,100)) > > button[text].setText(QtCore.QString(user_Handle)) > > button.setGeometry(xval,yval, 130, 130) > > button.connect(button, QtCore.SIGNAL('clicked()'), > > partial(calluser, user_Handle)) > > > > Thank You > > > > Ahmed > > > > ___ > > PyQt mailing listPyQt@riverbankcomputing.com > > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > > > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Button Color
I am calling print just after using connect method . I think you are right it might get focus after displayed . On Wed, Aug 17, 2011 at 3:35 AM, Josh Stratton wrote: > I would assume it should print true if it's focused. Where are you > calling print? It might receive focus after you check if it has > focus. It might receive focus after the window is displayed. Not > sure, but that's a guess. > > On Tue, Aug 16, 2011 at 3:32 PM, uahmed wrote: > > Hi > > > > Thanks for the reply yes it is like that When i press tab it moves to > next > > button but When i use this command > > > > print close.hasFocus() > > > > It prints False , Does it indicate that it dont have Focus ? > > > > Thank You > > > > On Wed, Aug 17, 2011 at 3:26 AM, Josh Stratton > > > wrote: > >> > >> That looks like the default button that has focus if you were to hit > >> "Enter" sending an event to that button. Like if you were to hit tab, > >> the second button would receive the focus. You can check if the > >> button has focus by calling hasFocus() or clearing it by calling > >> clearFocus(). That should remove the focus (and coloring) if you > >> don't want it there. > >> > >> On Tue, Aug 16, 2011 at 3:03 PM, uahmed wrote: > >> > Hi , > >> > > >> > I am new in Pyqt , i am confuse on one thing whenever i make buttons > the > >> > first button color always have reddish layer . I am also attaching the > >> > code > >> > and Screen Shot . > >> > > >> > import sys > >> > from PyQt4 import QtGui, QtCore > >> > > >> > app = QtGui.QApplication(sys.argv) > >> > widget = QtGui.QWidget() > >> > > >> > widget.setGeometry(200, 100, 400, 300) > >> > widget.setWindowTitle('PyQt Application') > >> > > >> > close = QtGui.QPushButton(QtGui.QIcon('default.gif'), 'Close', widget) > >> > close.setGeometry(10, 10, 100, 30) > >> > close1 = QtGui.QPushButton(QtGui.QIcon('default.gif'), 'Close', > widget) > >> > close1.setGeometry(10, 50, 100, 30) > >> > > >> > def hello(): > >> > print 'hello everybody' > >> > > >> > widget.connect(close, QtCore.SIGNAL('clicked()'), hello) > >> > widget.connect(close1, QtCore.SIGNAL('clicked()'), hello) > >> > > >> > widget.show() > >> > sys.exit(app.exec_()) > >> > > >> > ___ > >> > PyQt mailing listPyQt@riverbankcomputing.com > >> > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > >> > > > > > > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
Re: [PyQt] Button Color
Hi Thanks for the reply yes it is like that When i press tab it moves to next button but When i use this command print close.hasFocus() It prints False , Does it indicate that it dont have Focus ? Thank You On Wed, Aug 17, 2011 at 3:26 AM, Josh Stratton wrote: > That looks like the default button that has focus if you were to hit > "Enter" sending an event to that button. Like if you were to hit tab, > the second button would receive the focus. You can check if the > button has focus by calling hasFocus() or clearing it by calling > clearFocus(). That should remove the focus (and coloring) if you > don't want it there. > > On Tue, Aug 16, 2011 at 3:03 PM, uahmed wrote: > > Hi , > > > > I am new in Pyqt , i am confuse on one thing whenever i make buttons the > > first button color always have reddish layer . I am also attaching the > code > > and Screen Shot . > > > > import sys > > from PyQt4 import QtGui, QtCore > > > > app = QtGui.QApplication(sys.argv) > > widget = QtGui.QWidget() > > > > widget.setGeometry(200, 100, 400, 300) > > widget.setWindowTitle('PyQt Application') > > > > close = QtGui.QPushButton(QtGui.QIcon('default.gif'), 'Close', widget) > > close.setGeometry(10, 10, 100, 30) > > close1 = QtGui.QPushButton(QtGui.QIcon('default.gif'), 'Close', widget) > > close1.setGeometry(10, 50, 100, 30) > > > > def hello(): > > print 'hello everybody' > > > > widget.connect(close, QtCore.SIGNAL('clicked()'), hello) > > widget.connect(close1, QtCore.SIGNAL('clicked()'), hello) > > > > widget.show() > > sys.exit(app.exec_()) > > > > ___ > > PyQt mailing listPyQt@riverbankcomputing.com > > http://www.riverbankcomputing.com/mailman/listinfo/pyqt > > > ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Text and Image Alignment
HI I want to do alignment in image and text , i want that image should be on center top and text should be at the bottom of image . I search for it but didnt get the relevant search result . Can you please tell me how to do that ? Chunk of Code for Button Without Text: button = QtGui.QPushButton(widget) button.setIcon(QtGui.QIcon('default.gif')) button.setIconSize(QtCore.QSize(100,100)) button.setGeometry(xval,yval, 130, 130) button.connect(button, QtCore.SIGNAL('clicked()'), partial(calluser, user_Handle)) Chunk of Code for Button With Text: button = QtGui.QPushButton(widget) button.setIcon(QtGui.QIcon('default.gif')) button.setIconSize(QtCore.QSize(100,100)) button[text].setText(QtCore.QString(user_Handle)) button.setGeometry(xval,yval, 130, 130) button.connect(button, QtCore.SIGNAL('clicked()'), partial(calluser, user_Handle)) Thank You Ahmed <>___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] tkinter after method in pyqt
Hi In tkinter i use after method to recall the function after particular interval time and that function do the the changes in GUI . What i should use to do changes in Pyqt GUI ? Thank you Ahmed ___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt
[PyQt] Button Color
Hi , I am new in Pyqt , i am confuse on one thing whenever i make buttons the first button color always have reddish layer . I am also attaching the code and Screen Shot . import sys from PyQt4 import QtGui, QtCore app = QtGui.QApplication(sys.argv) widget = QtGui.QWidget() widget.setGeometry(200, 100, 400, 300) widget.setWindowTitle('PyQt Application') close = QtGui.QPushButton(QtGui.QIcon('default.gif'), 'Close', widget) close.setGeometry(10, 10, 100, 30) close1 = QtGui.QPushButton(QtGui.QIcon('default.gif'), 'Close', widget) close1.setGeometry(10, 50, 100, 30) def hello(): print 'hello everybody' widget.connect(close, QtCore.SIGNAL('clicked()'), hello) widget.connect(close1, QtCore.SIGNAL('clicked()'), hello) widget.show() sys.exit(app.exec_()) <>___ PyQt mailing listPyQt@riverbankcomputing.com http://www.riverbankcomputing.com/mailman/listinfo/pyqt