Re: [PyKDE] Using QScrollView to manage a changing list of widge

2003-02-17 Thread Jonathan Gardner
On Monday 17 February 2003 21:03, Jim Bublitz wrote:
> On 18-Feb-03 Jonathan Gardner wrote:

> >
> > Anyways, it works fine as long as I am looking at a different tab
> > as I change the patient. If I am looking at it, it clears, but
> > won't show what has been added.
> >
>
> After just taking a quick look, there's a couple of things I'd try:
> first, you might want to try calling the show () methods for the
> QLabels or QVBox, or otherwise forcing a redraw (show () is usually
> the best way). Second, you might want to look at QWidgetStack, which
> is designed for adding/removing widgets (there's an example in the
> Qt docs). I've had some flakiness (but nothing related to an
> example like yours) with removeChild, but could just be my code too.
>

Jim, thanks for the tip. As far as QWidgetStack, is concerned, it wasn't quite 
what I was looking for.

However, putting in a QWidget.show() (self.vbox.show()) after modifying the 
contents solved the problem. I'll post a simple example of the code that 
works if anyone is interested.

-- 
Jonathan Gardner
[EMAIL PROTECTED]
Python Qt perl apache and linux

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



RE: [PyKDE] Using QScrollView to manage a changing list of widge

2003-02-17 Thread Jim Bublitz

On 18-Feb-03 Jonathan Gardner wrote:
> I'm working on some software for a client here, and I've been> 
> thinking of several ways to handle a situation that has come up
> more than once.
 
> A single patient can have several insurance companies they are
> subscribed to.  Not just the insurances that are current, but
> previous insurances as well. Most common is only one, but
> having two or three is very common.
 
> One idea I came up with was using QScrollView.  It would have
> only one child -- a QVBox. This is similar to the first method
> of using it mentioned in the Qt documentation.
 
> That QVBox would have the list of patient insurance widgets.The
> patient insurance list needs to be able to grow and shrink (as
> I add or remove insurance companies) or disappear altogether
> and be repopulated (when I switch what patient I am looking at).
 
> I implemented something that just lists QLabels rather than
> patient insurance widgets.
 
> One more note: The insurance list is just one tab among many on
> the main widget.
 
> class Insurance_Tab(QWidget):
 
> def __init__(self, parent=None, name=None, fl=0):
> QWidget.__init__(self, parent, name, fl)
 
> lo = QVBoxLayout(self,0,6)
 
> self.sv = QScrollView(self, "Insurance_Tab_ScrollView")
> self.sv.setHScrollBarMode(QScrollView.AlwaysOff)
 
> self.vbox = QVBox(self.sv.viewport())
> self.sv.addChild(self.vbox)
 
> lo.addWidget(self.sv)
 
> def set_patient(self, patient):
> self.sv.removeChild(self.vbox)
> del self.vbox
> self.vbox = QVBox(self.sv.viewport())
 
> if patient:
> sql = """
> SELECT object_id
> FROM c_patient_insurance
> WHERE patient=%d
> """ % patient.object_id
> for i in db.query(sql).dictresult():
> print i
> QLabel(str(i['object_id']), self.vbox)
 
> Anyways, it works fine as long as I am looking at a different tab
> as I change the patient. If I am looking at it, it clears, but
> won't show what has been added.
 
> Any pointers would be great. Thanks in advance.
 
After just taking a quick look, there's a couple of things I'd try:
first, you might want to try calling the show () methods for the
QLabels or QVBox, or otherwise forcing a redraw (show () is usually
the best way). Second, you might want to look at QWidgetStack, which
is designed for adding/removing widgets (there's an example in the
Qt docs). I've had some flakiness (but nothing related to an
example like yours) with removeChild, but could just be my code too.


Jim

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



[PyKDE] Using QScrollView to manage a changing list of widgets

2003-02-17 Thread Jonathan Gardner
I'm working on some software for a client here, and I've been thinking of 
several ways to handle a situation that has come up more than once.

A single patient can have several insurance companies they are subscribed to. 
Not just the insurances that are current, but previous insurances as well. 
Most common is only one, but having two or three is very common.

One idea I came up with was using QScrollView.  It would have only one child 
-- a QVBox. This is similar to the first method of using it mentioned in the 
Qt documentation.

That QVBox would have the list of patient insurance widgets.The patient 
insurance list needs to be able to grow and shrink (as I add or remove 
insurance companies) or disappear altogether and be repopulated (when I 
switch what patient I am looking at).

I implemented something that just lists QLabels rather than patient insurance 
widgets.

One more note: The insurance list is just one tab among many on the main 
widget.

class Insurance_Tab(QWidget):

def __init__(self, parent=None, name=None, fl=0):
QWidget.__init__(self, parent, name, fl)

lo = QVBoxLayout(self,0,6)

self.sv = QScrollView(self, "Insurance_Tab_ScrollView")
self.sv.setHScrollBarMode(QScrollView.AlwaysOff)

self.vbox = QVBox(self.sv.viewport())
self.sv.addChild(self.vbox)

lo.addWidget(self.sv)

def set_patient(self, patient):
self.sv.removeChild(self.vbox)
del self.vbox
self.vbox = QVBox(self.sv.viewport())

if patient:
sql = """
SELECT object_id
FROM c_patient_insurance
WHERE patient=%d
""" % patient.object_id
for i in db.query(sql).dictresult():
print i
QLabel(str(i['object_id']), self.vbox)

Anyways, it works fine as long as I am looking at a different tab as I change 
the patient. If I am looking at it, it clears, but won't show what has been 
added.

Any pointers would be great. Thanks in advance.

-- 
Jonathan Gardner
[EMAIL PROTECTED]
Python Qt perl apache and linux

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde



Re: [PyKDE] Eric3 push button

2003-02-17 Thread Detlev Offenbach
Hi,

> When I go to attach some code to a command button, the skeleton
> function is in C++ syntax.  How do I tell Eric I want to do Python
> code?
>

>From your short description I guess, that you are working in Qt-Designer 
and you are trying to add some code to the command button action. As far 
as I know (I haven't done this, s. below), you simply add your python 
code between the c++ skeletton. pyuic will extract it and produce the 
code.

I personally prefer the subclassing approach. I am doing my dialog in 
Qt-Designer and subclass it in my Python class. This class implements 
the handler methods and any other methods that are necessary.

However, your problem is not an eric3 problem.

Detlev
-- 
Detlev Offenbach
[EMAIL PROTECTED]

___
PyKDE mailing list[EMAIL PROTECTED]
http://mats.gmd.de/mailman/listinfo/pykde