Re: [PyQt] QUrl paths under Windows seem weird

2009-02-06 Thread Sergio Jovani
A Divendres 06 Febrer 2009 14:48:39, Grzegorz Adam Hankiewicz va escriure:
 Hello.

 I'm implementing a drag and drop application where the user drags
 files from the explorer and drops them on a label. The label processes
 the files and loads them.

 Under MacOSX this is working all well, but under Windows I am getting
 paths like u/C:/Documents and Settings/blah blah. Certainly the
 leading slash is not welcome. How come it got into there and how
 should I remove it?

 I know I can remove the first slash under Windows (I've just done it
 and works ok), but I would prefer to not have platform specific code.
 Is there any Qt normalization path which will return something I can
 pass to open() without having to parse it first?
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Hi,

Even it is not a Qt method, you can do it with os.path.normcase().

Ciao.
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QUrl paths under Windows seem weird

2009-02-06 Thread Sergio Jovani
A Divendres 06 Febrer 2009 15:42:30, Grzegorz Adam Hankiewicz va escriure:
 El 06/02/2009, a las 15:19, Sergio Jovani escribió:
  Hi,
 
  Even it is not a Qt method, you can do it with os.path.normcase().

 That function doesn't help at all, did you try it yourself?

 Python 2.5.2 (r252:60911, Feb 21 2008, 13:11:45) [MSC v.1310 32 bit
 (Intel)] on
 win32
 Type help, copyright, credits or license for more information.

   import os
   os.path.exists(os.path.normcase(u/C:/Documents and Settings))

 False

   os.path.exists(os.path.normcase(uC:/Documents and Settings))

 True

 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

Oh, sorry, I did not understood, I thought you wanted only change / for \. 
That is strange, maybe a PyQt bug?

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Dialogue box with hyperlink

2009-01-27 Thread Sergio Jovani
A Dimarts 27 Gener 2009 21:11:22, Darryl Wallace va escriure:
 Hello,

  Has anyone somewhere an example code of a small dialogue box which
  contains a hyperlink to a web site?
 
  I would like to point the user to some web site, in the confirmation
  dialogue I want to show.

 Quick way is to use a QLabel with qt /qt tags in the string and then
 using the standard html for creating a hyperlink:

 For example:

 dialogLabel = QtGui.QLabel(qt Please visit a href =
 http://www.google.ca Google/ato search./qt)

 darryl
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Hi, I think that will open any web browser. If you want web browser be opened 
on clicking, you have to add:

dialogLabel = QtGui.QLabel(qt Please visit a href = 
http://www.google.caGoogle/ato search./qt)
self.connect(dialogLabel, SIGNAL(linkActivated(QString)), self.OpenURL)

def OpenURL(self, URL):
  QtGui.QDesktopServices().openUrl(QUrl(URL))


Sorry if this is wrong :P
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QDesktopServices openUrl doesn't work if URL-Path has spaces etc.

2009-01-26 Thread Sergio Jovani
Hi,

You have to specify fromLocalFile() in QUrl():

DesktopServices().openUrl(QUrl.fromLocalFile(/home/piotr/test2/lol
bar/photo_4900_8ea80c_huge.jpg))

Bye!

2009/1/26 piotr maliński riklau...@gmail.com:


 2009/1/26 David Boddie da...@boddie.org.uk

 On Sun Jan 25 22:17:46 GMT 2009, piotr malinski wrote:

  Here is an example script:
  ~
  from PyQt4.QtCore import *
  from PyQt4.QtGui import *
 
  d = QDesktopServices()
 
  x = '/home/piotr/test2/lol bar/photo_4900_8ea80c_huge.jpg'
  print QUrl(x).isValid()
  d.openUrl(QUrl(x))
  ~~~
  The problem is it won't work if there is a space in the path - lol
  bar, for spaceless paths it works (also for example on windows it
  needs paths with slashes not backslashes...). How can I make the path
  valid for QDesktopServices? (the QUrl itself is valid)

 Perhaps try encoding the URL first:


 http://www.riverbankcomputing.com/static/Docs/PyQt4/html/qurl.html#toEncoded

 This may be related to a bug that was apparently fixed in Qt 4.4.0:


 http://www.qtsoftware.com/developer/task-tracker/index_html?method=entryid=194046

 You don't say which version of Qt you are using. If it's later than Qt
 4.4.0,
 it would be good if you could report this as a bug using the Task Tracker.

 David
 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt


 PyQt 4.4.4-r1, Qt 4.4.2, and using:
 ~
 from PyQt4.QtCore import *
 from PyQt4.QtGui import *

 d = QDesktopServices()

 x = '/home/piotr/test2/lol bar/photo_4900_8ea80c_huge.jpg'
 x = unicode(QUrl(x).toEncoded()
 print x
 print QUrl(x).isValid()
 d.openUrl(QUrl(x))
 ~~
 Doesn't help. So is it a Qt bug?

 ___
 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] QDesktopServices openUrl doesn't work if URL-Path has spaces etc.

2009-01-26 Thread Sergio Jovani
A Dilluns 26 Gener 2009 09:59:58, piotr maliński va escriure:
 print QUrl.fromLocalFile(x).isValid()
 d.openUrl(QUrl.fromLocalFile(x))

 It's valid, but still doesn't work


It's rare... It works for me... What Platform do you use? If Linux, what 
desktop environment?

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Replace HTML characters

2009-01-21 Thread Sergio Jovani
Hi list,

I would like to ask if there is any Qt-way to converting HTML
characters like Aacute;, Oacute; to Unicode characters (Á,
Ó). If there is not a Qt-way I would like to know if there is a
Python module/function to doing that. I only found this:
https://fisheye.toolserver.org/browse/~raw,r=5846/pywikipedia/trunk/pywikipedia/spellcheck.py
(removeHTML function).

Thanks!

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Threads with PyQt. Qt's or Python's?

2009-01-19 Thread Sergio Jovani
Hi,

I always used QThread and emit() in order to communicate with main
QThread without problems:

thread = Thread(self)
self.connet(thread, SIGNAL(Signal))
thread.start()

2009/1/19 Christoph Burgmer chri...@gmx.de:
 Am Monday, 19. January 2009 schrieb Giovanni Bajo:

 On 1/19/2009 3:13 PM, eliben wrote:

  I've seen various references to this issue before, but nothing to fully

  address it as I'd expect.

 

  Can you comment on the pros and cons of using QThread vs Python's
  threads

  with PyQt?

 

  I'll begin: on the surface, Python's threads make more sense because

  they're Qt independent and can be ported between apps that don't

  necessarily depend on Qt (for example a web version of a GUI app). The

  Python thread API is powerful enough for all uses, it seems.

 

  However, there are concerns. Perhaps QThreads are more efficient? Or

  maybe more tightly integrated with the other parts of PyQt, so it's

  easier to use them?



 It's mostly the same. The main difference is that QThreads are better

 integrated with Qt (asynchrnous signals/slots, event loop, etc.). Also,

 you can't use Qt from a Python thread (you can't for instance post event

 to the main thread through QApplication.postEvent): you need a QThread

 for that to work.

 I am doing a

 QCoreApplication.postEvent()

 out of run() from a threading.Thread class without any problems.

 Christoph

 ___
 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] Threads with PyQt. Qt's or Python's?

2009-01-19 Thread Sergio Jovani
Sorry!


thread = Thread(self)
self.connet(thread, SIGNAL(Signal), self.Slot)
thread.start()

2009/1/19 Sergio Jovani lese...@gmail.com:
 Hi,

 I always used QThread and emit() in order to communicate with main
 QThread without problems:

 thread = Thread(self)
 self.connet(thread, SIGNAL(Signal))
 thread.start()

 2009/1/19 Christoph Burgmer chri...@gmx.de:
 Am Monday, 19. January 2009 schrieb Giovanni Bajo:

 On 1/19/2009 3:13 PM, eliben wrote:

  I've seen various references to this issue before, but nothing to fully

  address it as I'd expect.

 

  Can you comment on the pros and cons of using QThread vs Python's
  threads

  with PyQt?

 

  I'll begin: on the surface, Python's threads make more sense because

  they're Qt independent and can be ported between apps that don't

  necessarily depend on Qt (for example a web version of a GUI app). The

  Python thread API is powerful enough for all uses, it seems.

 

  However, there are concerns. Perhaps QThreads are more efficient? Or

  maybe more tightly integrated with the other parts of PyQt, so it's

  easier to use them?



 It's mostly the same. The main difference is that QThreads are better

 integrated with Qt (asynchrnous signals/slots, event loop, etc.). Also,

 you can't use Qt from a Python thread (you can't for instance post event

 to the main thread through QApplication.postEvent): you need a QThread

 for that to work.

 I am doing a

 QCoreApplication.postEvent()

 out of run() from a threading.Thread class without any problems.

 Christoph

 ___
 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] Problem calling a window

2009-01-15 Thread Sergio Jovani
Hi,

If you want to call a QMainWindow from a QDialog you have to set a
parent. exec_() gets attribute error because I thought it was a
QDialog :P

Try with this:

wndMain = Pro2MainWindow(self) # --- set as parent QDialog
wndMain.showMaximized()
self.hide()

2009/1/15 Sandro Dutra hexo...@gmail.com:
 Sorry for the delay... it's the time, it's the time...

 I used Eric4 and QtDesigner, so the Pro2MainWindow it's only the window
 without the widgets (I only want to test the call), here's the code:

 ---Pro2MainWindow Code---
 # -*- coding: utf-8 -*-

 
 Module implementing Pro2MainWindow.
 

 from PyQt4.QtGui import QMainWindow
 from PyQt4.QtCore import pyqtSignature

 from Ui_Pro2MainWindow import Ui_Pro2MainWindow

 class Pro2MainWindow(QMainWindow, Ui_Pro2MainWindow):
 
 Class documentation goes here.
 
 def __init__(self, parent = None):
 
 Constructor
 
 QMainWindow.__init__(self, parent)
 self.setupUi(self)

 The setupUi, only call the definitions of the ui generated by QtDesigner,
 and here's the complete code for the login screen:
 # -*- coding: utf-8 -*-

 
 Module implementing DialogPro2Login.
 

 from PyQt4.QtGui import QDialog,  QMessageBox,  QApplication
 from PyQt4.QtCore import pyqtSignature

 from Ui_Pro2Login import Ui_DialogPro2Login
 from Pro2MainWindow import Pro2MainWindow
 from db.database import Pro2db

 import MySQLdb,  sys

 class DialogPro2Login(QDialog, Ui_DialogPro2Login):
 
 Class documentation goes here.
 
 def __init__(self, parent = None):
 
 Constructor
 
 QDialog.__init__(self, parent)
 self.setupUi(self)

 @pyqtSignature()
 def on_pushButton_enter_clicked(self):
 user = self.lineEdit_user.text()
 passw = self.lineEdit_passw.text()
 if user ==  or passw == :
 QMessageBox.information(self,  ERRO,  uPor favor, entre com o
 usuário e senha.,  OK)
 else:
 try:
 p2db = Pro2db(str(user),  str(passw)) ### Here is where I
 want to call the mainwindow 
 wndMain = Pro2MainWindow()
 wndMain.exec_()
 wndMain.showMaximized()
 self.hide()
 ##
 except MySQLdb.Error,  error_code:
 if error_code[0] == 1045:
 message = uAcesso negado para o usuário: %s %user
 elif error_code[0] == 2003:
 message = uNão foi possível realizar a conexão.
 else:
 message = uErro desconhecido.\nCódigo administrativo:
 %s - %s. %(error_code[0],  error_code[1])
 QMessageBox.information(self, Falha no acesso,  uO
 servidor informa:\n%s %message,  OK)

 @pyqtSignature()
 def on_pushButton_exit_clicked(
 self):
 self.close()

 If you need more info tell me,
 Thanks for the attention to a so noob problem.
 Sandro Dutra - Brazil.
 ___
 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] Problem calling a window

2009-01-14 Thread Sergio Jovani
It would be good you post more code, at least, Pro2MainWindow class.

2009/1/14 Sandro Dutra hexo...@gmail.com:
 I get a AttibuteError in mainWnd.exec_()

 If necessary, I can upload the complete code.

 Thanks in advance.

 2009/1/13 Sergio Jovani lese...@gmail.com

 Hi,

 This is a little piece of code, but you can try with:

mainWnd = Pro2MainWindow()
mainWnd.exec_()
mainWnd.showMaximized()
self.hide()

 2009/1/13 Sandro Dutra hexo...@gmail.com:
  I'm writing a solution using Python, Qt and MySQL, I create the login
  screen
  and set all the errors...
 
  The problem is: When the user do the correct login in MySQL, I want the
  login screen to close, and the whole application show.
 
  The code when the button Enter is pressed:
  ---
  def on_pushButton_enter_clicked(self):
  user = self.lineEdit_user.text()
  passw = self.lineEdit_passw.text()
  if user ==  or passw == :
  QMessageBox.information(self,  ERRO,  uPor favor, entre
  com o
  usuário e senha.,  OK)
  else:
  try:  If the login is made, the application is
  launch and the login screen is closed.
  p2db = Pro2db(str(user),  str(passw))
  mainWnd = Pro2MainWindow()
  mainWnd.showMaximized()
  self.close()
   ###
  except MySQLdb.Error,  error_code:
  if error_code[0] == 1045:
  message = uAcesso negado para o usuário: %s %user
  elif error_code[0] == 2003:
  message = uNão foi possível realizar a conexão.
  else:
  message = uErro desconhecido.\nCódigo
  administrativo:
  %s - %s. %(error_code[0],  error_code[1])
  QMessageBox.information(self, Falha no acesso,  uO
  servidor informa:\n%s %message,  OK)
  ---
 
  Anyone can help?
 
  Thanks in advance,
  Sandro Dutra,
  Brazil.
 
  ___
  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] Pause QProcess

2009-01-13 Thread Sergio Jovani
Hi list!

In my application I've created a process with QProcess and 'ffmpeg'
program. I offer to user cancelling process calling kill() method, but
I don't know if pausing it would be possible.

Is there any way to pause QProcess in a safe-way?

Thanks!
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Problem calling a window

2009-01-13 Thread Sergio Jovani
Hi,

This is a little piece of code, but you can try with:

mainWnd = Pro2MainWindow()
mainWnd.exec_()
mainWnd.showMaximized()
self.hide()

2009/1/13 Sandro Dutra hexo...@gmail.com:
 I'm writing a solution using Python, Qt and MySQL, I create the login screen
 and set all the errors...

 The problem is: When the user do the correct login in MySQL, I want the
 login screen to close, and the whole application show.

 The code when the button Enter is pressed:
 ---
 def on_pushButton_enter_clicked(self):
 user = self.lineEdit_user.text()
 passw = self.lineEdit_passw.text()
 if user ==  or passw == :
 QMessageBox.information(self,  ERRO,  uPor favor, entre com o
 usuário e senha.,  OK)
 else:
 try:  If the login is made, the application is
 launch and the login screen is closed.
 p2db = Pro2db(str(user),  str(passw))
 mainWnd = Pro2MainWindow()
 mainWnd.showMaximized()
 self.close()
  ###
 except MySQLdb.Error,  error_code:
 if error_code[0] == 1045:
 message = uAcesso negado para o usuário: %s %user
 elif error_code[0] == 2003:
 message = uNão foi possível realizar a conexão.
 else:
 message = uErro desconhecido.\nCódigo administrativo:
 %s - %s. %(error_code[0],  error_code[1])
 QMessageBox.information(self, Falha no acesso,  uO
 servidor informa:\n%s %message,  OK)
 ---

 Anyone can help?

 Thanks in advance,
 Sandro Dutra,
 Brazil.

 ___
 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] Application built with py2exe doesn't display jpg/gif images in QWebView

2009-01-13 Thread Sergio Jovani
I had this problem. I solved it copying
C:\Python26\Lib\site-packages\PyQt4\plugins\imageformats\qjpeg4.dll to
dist\imageformats\.

I my build script I have:

build.bat
==
C:\python26\python.exe setup.win32.py py2exe --includes sip
...
mkdir dist\imageformats
copy C:\Python26\Lib\site-packages\PyQt4\plugins\imageformats\qjpeg4.dll
dist\imageformats\*



2009/1/13 piotr maliński riklau...@gmail.com:
 I have a mini-browser in my app, and runned from source on Windows it
 works ok, but the binary made with Py2exe doesn't work ok - it doesn't
 display JPG/GIF images. PNG work.

 Adding this:

 data_files=[(.,[qjpeg4.dll, qgif4.dll, qico4.dll]

 and copying the DLLs from PyQt4 doesn't help. Can this be fixed somehow?
 ___
 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] Problem with apps build with Py2exe

2009-01-09 Thread Sergio Jovani
Hi,

That problem appeared on my software. The best choice is to use
version 2.5. PyQt4 for Python 2.6 compiled code requires MSCV to work.

Bye!

2009/1/9 piotr maliński riklau...@gmail.com:
 Yes, Python, 2.6 and latest PyQt4 build for windows/Py2.6

 2009/1/9 Giovanni Bajo ra...@develer.com

 On ven, 2009-01-09 at 10:07 +0100, piotr maliński wrote:
  Some MS Windows users have problem running PyQt4 applications -
  exe/binary builds made with Py2exe. The problem is that Windows
  displays a message like this (translation from Polish) This
  application can't be run as it configuration is wrong. Problem may be
  solved by reinstalling the script.
 
  It works for some users, and for some don't (plus it's no install
  run.exe made from run.py). Any ideas why Windows makes such
  problems? :)

 Are you using Python 2.6?
 --
 Giovanni Bajo
 Develer S.r.l.
 http://www.develer.com




 ___
 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] Desktop Filedialog Integration

2008-12-27 Thread Sergio Jovani
Hi!

I wanted to add desktop file dialog integration to my program. I've
written some code to do checks in order to get what program it have to
use (zenity, kdialog). I used QProcess in order to launch dialogs and
all work very fine.

Now I want get same relationship between windows (QMainWindow and
kdialog/zenity) like when QMainWindow launchs QDialog with exec_()
function, that is, I can view QMainWindow operations but until I close
QDialog I can't use any mainwindow widget. How can I do this?

Thanks!

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QThread problem

2008-12-10 Thread Sergio Jovani
El Monday 08 December 2008 03:53:28 vàreu escriure:
 On Mon, Dec 8, 2008 at 12:53 AM, Sergio Jovani [EMAIL PROTECTED] wrote:
  Hi all,
 
  I'm developing a downloads application and I have created a QThread for
  that reason. I start the QThread with no problems, but when I try
  terminate it clicking on cancel pushbutton, I can't, application freezes.
  Thanks in advance. Here the code:
 
  ---
 
  class MainWindow(QMainWindow):
 def __init__(self, parent = None):
 QMainWindow.__init__(self, parent)
 ...
 self.pbCancel=QPushButton(self.tr(Cancel))
 self.connect(self.pbCancel, SIGNAL(clicked()),
  self.cancel) ...
 def download(self):
 ...
 self.threadDownload = Download(url, path, filename)
 self.threadDownload.start()
 
 def cancel(self):
 self.threadDownload.terminate()
 self.threadDownload.wait()
 
  class Download(QThread):
 def __init__(self, url, path, filename, parent = None):
 QThread.__init__(self, parent)
 self.path=path
 self.url=url
 self.filename=filename
 
 def run(self):
 os.chdir(self.path)

  urllib.urlretrieve(self.url,self.filename,reporthook=self.myreporthook)


Dears subcribers,

A few days ago, I received a lot of help trying solve this problem. Thanks for 
that.

After testing and writing and erasing code, I discovered the main problem of 
this. QThread is powerful but also dangerous, it have to terminate in a safe 
way, if not, program will become unstable.

The main problem was the urllib2 function, because if a file is opened inside 
thread, file wll have to be closed inside thread in order to terminate properly 
the thread.

I hope this helps someone. I wrote a piece of code replacing 
urlllib.urlretrieve function. and doing this I can close opened file before to 
terminate thread.

---

class MainWindow(QMainWindow):
def __init__(self, parent = None):
QMainWindow.__init__(self, parent)
...
self.pbCancel=QPushButton(self.tr(Cancel))
self.connect(self.pbCancel, SIGNAL(clicked()), self.cancel)   
...
def download(self):
...
self.threadDownload = Download(url, path, filename)
self.threadDownload.start()

def cancel(self):
self.threadDownload.interrupt() # Not terminate() !
self.threadDownload.wait()

class Download(QThread):
def __init__(self, url, path, filename, parent = None):
QThread.__init__(self, parent)
self.path=path
self.url=url
self.filename=filename
self.interrupted = False # We will have to change this to 
terminate thread!

def interrupt(self):
self.interrupted = True

def run(self):
os.chdir(self.path)
block_size = 4096
i = 0
counter = 0
temp = urllib2.urlopen(self.url)
headers = temp.info()
size = int(headers['Content-Length'])
data = open(self.filename, 'wb')
while i  size:
if not self.interrupted:
data.write(temp.read(block_size))
i += block_size
counter += 1
self.myreporthook(counter, block_size, size) # 
you can use reporthook!
else:
break   
data.close()
temp.close()

self.quit() # terminate() too dangerous, now we can use quit() 
or exit(int).

---

Thanks! See you!


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] QThread problem

2008-12-08 Thread Sergio Jovani
El Monday 08 December 2008 03:53:28 vàreu escriure:
 On Mon, Dec 8, 2008 at 12:53 AM, Sergio Jovani [EMAIL PROTECTED] wrote:
  Hi all,
 
  I'm developing a downloads application and I have created a QThread for
  that reason. I start the QThread with no problems, but when I try
  terminate it clicking on cancel pushbutton, I can't, application freezes.
  Thanks in advance. Here the code:
 
  ---
 
  class MainWindow(QMainWindow):
 def __init__(self, parent = None):
 QMainWindow.__init__(self, parent)
 ...
 self.pbCancel=QPushButton(self.tr(Cancel))
 self.connect(self.pbCancel, SIGNAL(clicked()),
  self.cancel) ...
 def download(self):
 ...
 self.threadDownload = Download(url, path, filename)
 self.threadDownload.start()
 
 def cancel(self):
 self.threadDownload.terminate()
 self.threadDownload.wait()
 
  class Download(QThread):
 def __init__(self, url, path, filename, parent = None):
 QThread.__init__(self, parent)
 self.path=path
 self.url=url
 self.filename=filename
 
 def run(self):
 os.chdir(self.path)

  urllib.urlretrieve(self.url,self.filename,reporthook=self.myreporthook)
  ___
  PyQt mailing listPyQt@riverbankcomputing.com
  http://www.riverbankcomputing.com/mailman/listinfo/pyqt

def download(self):
...
self.threadDownload = Download(url, path, filename)
self.threadDownload.start()
qApp.processEvents()

Hi,

Thanks for reply, but this does not solve the problem. I've tried and it still 
freeze when I want to terminate QThread.

---

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QThread problem

2008-12-08 Thread Sergio Jovani
 On lun, 2008-12-08 at 01:53 +0100, Sergio Jovani wrote:
  I'm developing a downloads application and I have created a QThread
  for that reason.

 You don't need threads to download files with PyQt. In fact, it's far
 easier without.

Hi, I would like know it! Thanks.


___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QThread problem

2008-12-08 Thread Sergio Jovani
El Monday 08 December 2008 17:19:42 vàreu escriure:
 Hello,

 Sergio Jovani wrote

  class Download(QThread):
  def __init__(self, url, path, filename, parent = None):
  QThread.__init__(self, parent)
  self.path=path
  self.url=url
  self.filename=filename
 
  def run(self):
  os.chdir(self.path)
  
  urllib.urlretrieve(self.url,self.filename,reporthook=self.myreporthook)

 I don't know if this would be the problem, because it looks like you
 have trimmed the code to only contain relevant parts.  I have a couple
 questions.  If you don't terminate, does it properly retrieve the item
 at the url?

 Your code here for the Download class has no definition of
 self.myreporthook so could that be the problem?

 darryl


Hi,

When I remove wait() after terminate(), application does not freeze and 
download seems to be cancelled, file isn't retrieved, but I get True from 
isRunning() execution, it seems thread has not terminated.

self.myreporthook is not important, if I remove it, thread works equal.

Thanks!

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] QThread problem

2008-12-08 Thread Sergio Jovani
 I'm going to throw this out there, you should exchange information via
 signals/slots.  When you get a cancel use terminate() slot.  That will
 stop it from freezing you program from the looks of it.

I tried and I get the same running terminate() slot from signal and outside.

Thanks.

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


Re: [PyQt] Re: Strings with variables in TS-File can not be loaded

2008-09-16 Thread Sergio Jovani
El Tuesday 16 September 2008 15:55:23 Alberto Berti va escriure:
  Sergio == Sergio Jovani [EMAIL PROTECTED] writes:

 Sergio Source code: DurationMsg=self.tr(Duration: %s min %
 Sergio duration)

 mmm but here the string gets formatted before the callo to tr(), it
 can never be translated...

 Sergio Translation: Duració: %s min

 ___
 PyQt mailing listPyQt@riverbankcomputing.com
 http://www.riverbankcomputing.com/mailman/listinfo/pyqt

I'm sorry to be so stupid, but I don't understand you are telling to me. How 
should I write this??

Thanks for your patience!

___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt


[PyQt] Call a window from other parent window

2007-10-16 Thread Sergio Jovani Guzmán
Hi all!

I am learning PyQt and I have a question.

I have two classes, one for each widget:

==
class Main(QMainWindow):
def __init__(self):
QMainWindow.__init__(self)
loadUi(frmmain.ui, self)

class Conectar(QDialog):

def __init__(self):
QDialog.__init__(self)
loadUi(frmconectar.ui, self)
=

My question is, how can I call and show a widget from other with parent?

For example, open Conectar() window from Main() window?

Many thanks!

-- 
Sergio Jovani
___
PyQt mailing listPyQt@riverbankcomputing.com
http://www.riverbankcomputing.com/mailman/listinfo/pyqt