[Tutor] Trouble with "RuntimeError: underlying C/C++ object has been deleted".

2007-04-17 Thread Lawrence Shafer

Hello List,

I am just learning Python/PyQt4, and have a problem I cannot figure out.
Here's what happens.

Traceback (most recent call last):
  File "iac.py", line 124, in on_actionOpen_triggered
self.open()
  File "iac.py", line 66, in open
if self.isUntitled and self.textBrowser.document().isEmpty() and not
self.isWindowModified():
RuntimeError: underlying C/C++ object has been deleted


I have copied several parts of other programs, so that's probably where
this is coming from. All I want is to load a .txt file into
self.textBrowser, so some of the functionality is unneeded at this time,
except for filter saving and loading. If someone understands what is
going on, that would be great!

Files are attached.

Thanks!
Lawrence



iac.py
Description: application/python


filterEdit_ui.py
Description: application/python


iac_ui.py
Description: application/python
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] Trouble with "RuntimeError: underlying C/C++ object has been deleted".

2007-05-03 Thread Lawrence Shafer
Hello List,

I am just learning Python/PyQt4, and have a problem I cannot figure out.
Here's what happens.

Traceback (most recent call last):
File "iac.py", line 124, in on_actionOpen_triggered
  self.open()
File "iac.py", line 66, in open
  if self.isUntitled and self.textBrowser.document().isEmpty() and not
self.isWindowModified():
RuntimeError: underlying C/C++ object has been deleted


I have copied several parts of other programs, so that's probably where
this is coming from. All I want is to load a .txt file into
self.textBrowser, so some of the functionality is unneeded at this time,
except for filter saving and loading. If someone understands what is
going on, that would be great!

The source can be downloaded from here 
http://lawrence.orbwireless.net/iac_src.tar.gz

Thanks!
Lawrence


___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] underlying C/C++ object has been deleted

2007-10-24 Thread Lawrence Shafer
I am trying to convert a program with hand coded QT over to using UI 
files from QT Designer. I am getting the error below and do not 
understand what's going on. I have a feeling I need to add self. to 
something in here, but I'm not sure what. Is this enough code for you to 
see whats going on?? If not I can upload the project somewhere.  Thanks, 
Lawrence

The error,

Traceback (most recent call last):
  File "atf.py", line 113, in on_actionOpen_triggered
self.open()
  File "atf.py", line 56, in open
if self.isUntitled and self.textBrowser.document().isEmpty() and not 
self.isWindowModified():
RuntimeError: underlying C/C++ object has been deleted


Here is the first part of the code.

#!/usr/bin/env python
# iaC.py - A Qt4 Calculator example

import sys
from math import pi
from PyQt4 import QtCore, QtGui
from iac_ui import Ui_mainWindow
from filterEdit2_ui import Ui_filterEdit


class iaC(QtGui.QMainWindow):
sequenceNumber = 1
windowList = []

@QtCore.pyqtSignature("")
def __init__(self, fileName=None, parent=None):
QtGui.QMainWindow.__init__(self, parent)

self.init()
if fileName:
self.loadFile(fileName)
else:
self.setCurrentFile(QtCore.QString())

self.ui = Ui_mainWindow()
self.ui.setupUi(self)

# Set up delete, up, and down buttons on the main 
form==
if self.ui.listWidget.count() < 1:
self.ui.deleteButton.setEnabled(False)
else:
self.ui.deleteButton.setEnabled(True)

if self.ui.listWidget.count() < 2:
self.ui.upButton.setEnabled(False)
self.ui.downButton.setEnabled(False)
else:
self.ui.downButton.setEnabled(True)
self.ui.upButton.setEnabled(True)

# Save settings on 
close?===
def closeEvent(self, event):
if self.maybeSave():
self.writeSettings()
event.accept()
else:
event.ignore()

# ===Open File=
@QtCore.pyqtSignature("")
def open(self):
fileName = QtGui.QFileDialog.getOpenFileName(self)
print "Loading fileName", fileName
if not fileName.isEmpty():

if self.isUntitled and self.textBrowser.document().isEmpty() 
and not self.isWindowModified():
self.loadFile(fileName)
else:
other = MainWindow(fileName)
if other.isUntitled:
del other
return
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


Re: [Tutor] underlying C/C++ object has been deleted

2007-10-25 Thread Lawrence Shafer
Here's the whole code. Any help appreciated!

http://shaferlabs.pastebin.com/m32c82193

Also I was thinking I could set the progressbar to 64% like this.
self.progressBar.setProperty("value",QtCore.QVariant(64))
but it doesn't work. (AttributeError: progressBar) I think it has 
something to do with some stupid way I'm initializing the iac_ui.py 
file. Like I said, I'm not used to QTDesigner and complex programs like 
this. Again, any help appreciated!

Lawrence Shafer wrote:
> I am trying to convert a program with hand coded QT over to using UI 
> files from QT Designer. I am getting the error below and do not 
> understand what's going on. I have a feeling I need to add self. to 
> something in here, but I'm not sure what. Is this enough code for you to 
> see whats going on?? If not I can upload the project somewhere.  Thanks, 
> Lawrence
>
> The error,
>
> Traceback (most recent call last):
>   File "atf.py", line 113, in on_actionOpen_triggered
> self.open()
>   File "atf.py", line 56, in open
> if self.isUntitled and self.textBrowser.document().isEmpty() and not 
> self.isWindowModified():
> RuntimeError: underlying C/C++ object has been deleted
>
>
> Here is the first part of the code.
>
> #!/usr/bin/env python
> # iaC.py - A Qt4 Calculator example
>
> import sys
> from math import pi
> from PyQt4 import QtCore, QtGui
> from iac_ui import Ui_mainWindow
> from filterEdit2_ui import Ui_filterEdit
>
>
> class iaC(QtGui.QMainWindow):
> sequenceNumber = 1
> windowList = []
>
> @QtCore.pyqtSignature("")
> def __init__(self, fileName=None, parent=None):
> QtGui.QMainWindow.__init__(self, parent)
>
> self.init()
> if fileName:
> self.loadFile(fileName)
> else:
> self.setCurrentFile(QtCore.QString())
>
> self.ui = Ui_mainWindow()
> self.ui.setupUi(self)
>
> # Set up delete, up, and down buttons on the main 
> form==
> if self.ui.listWidget.count() < 1:
> self.ui.deleteButton.setEnabled(False)
> else:
> self.ui.deleteButton.setEnabled(True)
>
> if self.ui.listWidget.count() < 2:
> self.ui.upButton.setEnabled(False)
> self.ui.downButton.setEnabled(False)
> else:
> self.ui.downButton.setEnabled(True)
> self.ui.upButton.setEnabled(True)
>
> # Save settings on 
> close?===
> def closeEvent(self, event):
> if self.maybeSave():
> self.writeSettings()
> event.accept()
> else:
> event.ignore()
>
> # ===Open File=
> @QtCore.pyqtSignature("")
> def open(self):
> fileName = QtGui.QFileDialog.getOpenFileName(self)
> print "Loading fileName", fileName
> if not fileName.isEmpty():
>
> if self.isUntitled and self.textBrowser.document().isEmpty() 
> and not self.isWindowModified():
> self.loadFile(fileName)
> else:
> other = MainWindow(fileName)
> if other.isUntitled:
> del other
> return
> ___
> Tutor maillist  -  Tutor@python.org
> http://mail.python.org/mailman/listinfo/tutor
>
>   
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] os.sys

2007-10-28 Thread Lawrence Shafer
Why doesn't this fill otp with the output of ls?? (I know python has 
it's own file tools, I'm just playing around ;)

import os
cmd="""ls"""
otp=os.system(cmd)
print otp
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] importing

2007-11-04 Thread Lawrence Shafer
What is the difference between "from name import *" and "import name"?

The reason I ask is because I was using the former, and switched to the 
latter only to find out "NameError: global name 'name' is not defined" 
and I think using the latter is going to fix another problem I have. I 
just want to know what's going on and how to work with it.
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor


[Tutor] comparing dates

2007-11-23 Thread Lawrence Shafer
How would I compare these two dates and extract the difference in H:M:S??

22 Nov 2007 18:54:07
23 Nov 2007 23:24:23

Cheers,

Lawrence
___
Tutor maillist  -  Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor