![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#11 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
![]() |
|
|
|
|
|
|
#12 |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
I tried out your WHOIS in glade/GTK, coldDeath, and here's what I came up with. I'll write a tutorial to mirror your rather excellent one, if I have time.
Comparing GTK to Qt was interesting, too. GTK's main advantage is that Glade produces its output as an XML file, so there's no need to run pyuic, nor to write your Python in an ugly C wrapper. The disadvantage to using GTK, is that Glade simply isn't quite as good as Qt Designer. The layout system in Glade revolves around vboxes, hboxes and tables, so you really have to know what you're designing before you design it. Qt also appears to have more sensible default behavior than GTK; for instance, you didn't have to write a 'close' method for your Qt program. Glade also has a clunkier way of accessing widgets; 'self.glade.get_widget("textbox")', rather than Qt's "self.textbox" (something I tried to address with my small glade-wrapper). The other advantage to Qt is that it integrates seamlessly with the native Windows toolkit, whilst GTK isn't quite so transparent (though GTK-WIMP addresses a lot of these problems). Alas, Qt3 is not available in GPL form for Windows, so until PyQt4 comes out, cross-platform development is rather limited. Also, as an aside, you could improve your code by cutting out the temporary file and using the "popen2" module, instead. popen2 executes an external command, and opens up a file object for reading the output of the command, and a file object for writing input to the command. e.g: import popen2
read_file, write_file = popen2.popen2("whois " + address)
output_of_whois = read_file.read() |
|
|
|
|
|
#13 |
|
Expert Programmer
|
Interesting comparison.
I've never really fully tried GTK but i've had a go at Glade and I didn't like it too much. Qt4 will be great and it will just make Qt perfect. But as you said, its horrible writing your code in a C function. I didn't know about the popen2 module, it certainly looks good, thanks for showing me it ![]() NOTE to everyone using Qt-Designer with Python: You should do this: Edit>Preferences>C++ Editor>Untick Auto Indent box Otherwise coding in the built in editor is _hell_.
__________________
Join us at #programmingforums @ irc.freenode.net! My software never has bugs. It just develops random features.
|
|
|
|
|
|
#14 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
e.g. from qt import *
from form1 import *
from popen2 import *
import sys
class MyForm(Form1):
def whois(self):
whois, _ = popen2("whois " + self.lineEdit1.text().ascii())
self.textEdit1.setText(whois.read())
if __name__ == "__main__":
app = QApplication(sys.argv)
f = MyForm()
f.show()
app.setMainWidget(f)
app.exec_loop() |
|
|
|
|
|
|
#15 | |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
I didn't see that you were writing it all inline. Didn't know you could even do that actually. Qt4 doesn't do let you do the whole .ui.h thing, making QtDesigner purely a GUI designer and not a mini-IDE. Cool thing is that QtDesigner4 is a lot easier to embed into other IDEs, so KDevelop will have it integrated.
Quote:
output = os.popen("whois " + address).read() |
|
|
|
|
|
|
#16 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
|
|
|
|
|
|
|
#17 | |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Oh, one more thing
Quote:
|
|
|
|
|
|
|
#18 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
|
|
|
|
|
|
|
#19 |
|
Professional Programmer
Join Date: Apr 2005
Location: London, England
Posts: 459
Rep Power: 4
![]() |
Fairly trivial to work around, surely? All it would take is a simple function that runs pyuic on the .ui file, imports the created .py file, and returns the freshly imported module? Like 6 lines long.
|
|
|
|
|
|
#20 | |
|
Programming Guru
![]() Join Date: Aug 2005
Location: England
Posts: 1,499
Rep Power: 5
![]() |
Quote:
When I wrote my comparison, I was still thinking that Python code had to be written inline in the .ui.h file, which was why I said it was the main disadvantage. Now I consider the main disadvantage to be Glade's layout manager, which is a bit more rigid than QtDesigner's. |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|