[PyQt] [PyKDE] KConfigSkeleton/KConfigDialog combo not working

2008-03-27 Thread Adeodato Simó
Hello.

I'm having trouble porting my PyKDE3 KConfigSkeleton/KConfigDialog: it
behaves weird in KDE4.

I'm attaching a very small sample program. The weird behavior I'm
observing is:

  (a) on the first run, when no testrc file exists under ~/.kde, the
  value of MyOption is correctly set to False, but when I click on
  the Preferences button, the checkbox is checked (instead of not
  checked, at it'd correspond)

  (b) so I change in the dialog the value to True, when closing the
  dialog the LineEdit updates accordingly, and the option is written
  as true to the testrc file, but when I restart the program, it
  is set to False again

Can you reproduce? Is there something wrong with my code? (With KDE 3 it
worked just fine).

Thanks in advance,

-- 
Adeodato Simó dato at net.com.org.es
Debian Developer  adeodato at debian.org
 
- Oh! Uh, congratulations.
- For what?
- You know, your thing tomorrow, renewing your vows.
- You congratulate the groom. You offer the bride best wishes.
-- Luke and Emily
#! /usr/bin/env python

import sys
import testui
from PyQt4 import QtGui, QtCore
from PyKDE4 import kdeui, kdecore

class Preferences(kdeui.KConfigSkeleton):
def __init__(self):
kdeui.KConfigSkeleton.__init__(self)
self.setCurrentGroup('General')
self._my_option_item = self.addItemBool('MyOption', False, False)
self.readConfig()

def MyOption(self):
return self._my_option_item.property().toBool()

##

class PreferencesPage(QtGui.QWidget, testui.Ui_Dialog):
def __init__(self, parent=None):
QtGui.QWidget.__init__(self, parent)
self.setupUi(self)

##

class PreferencesDialog(kdeui.KConfigDialog):
def __init__(self, parent, name, preferences):
kdeui.KConfigDialog.__init__(self, parent, name, preferences)
self.page = PreferencesPage(self)
self.addPage(self.page, 'General')

##

class MainWindow(kdeui.KMainWindow):
def __init__ (self, *args):
kdeui.KMainWindow.__init__(self, *args)
self.widget = QtGui.QWidget(self)
self.line = QtGui.QLineEdit(self.widget)
self.button = QtGui.QPushButton('Preferences', self.widget)
self.preferences = Preferences()

layout = QtGui.QVBoxLayout()
layout.addWidget(self.line)
layout.addWidget(self.button)
self.widget.setLayout(layout)
self.setCentralWidget(self.widget)

self.slot_settings_changed() # initial value

self.connect(self.button, QtCore.SIGNAL('clicked (bool)'),
self.slot_preferences)

def slot_preferences(self):
if kdeui.KConfigDialog.showDialog('preferences dialog'):
return
else:
dialog = PreferencesDialog(self, 'preferences dialog', self.preferences)
self.connect(dialog, QtCore.SIGNAL('settingsChanged(const QString )'),
self.slot_settings_changed)
dialog.show()

def slot_settings_changed(self):
print 'applying preferences, MyOption =', self.preferences.MyOption()
self.line.setText(str(self.preferences.MyOption()))

def main():
kdecore.KCmdLineArgs.init(sys.argv, 'test', '', kdecore.ki18n('test'), '1.0')
application = kdeui.KApplication()
main_window = MainWindow()
main_window.show()
application.exec_()

if __name__ == '__main__':
main()


#!/usr/bin/env python
# Generated by pykdeuic4 from testui.ui on Thu Mar 27 15:55:57 2008
#
# WARNING! All changes to this file will be lost.
from PyKDE4 import kdecore
from PyKDE4 import kdeui
from PyQt4 import QtCore, QtGui

class Ui_Dialog(object):
def setupUi(self, Dialog):
Dialog.setObjectName(Dialog)
Dialog.resize(QtCore.QSize(QtCore.QRect(0,0,400,300).size()).expandedTo(Dialog.minimumSizeHint()))

self.vboxlayout = QtGui.QVBoxLayout(Dialog)
self.vboxlayout.setObjectName(vboxlayout)

self.kcfg_MyOption = QtGui.QCheckBox(Dialog)
self.kcfg_MyOption.setObjectName(kcfg_MyOption)
self.vboxlayout.addWidget(self.kcfg_MyOption)

spacerItem = QtGui.QSpacerItem(20,40,QtGui.QSizePolicy.Minimum,QtGui.QSizePolicy.Expanding)
self.vboxlayout.addItem(spacerItem)

self.retranslateUi(Dialog)
QtCore.QMetaObject.connectSlotsByName(Dialog)

def retranslateUi(self, Dialog):
Dialog.setWindowTitle(kdecore.i18n(Dialog))
self.kcfg_MyOption.setText(kdecore.i18n(Option))

ui version=4.0 
 classDialog/class
 widget class=QDialog name=Dialog 
  property name=geometry 
   rect
x0/x
y0/y
width400/width
height300/height
   /rect
  /property
  property name=windowTitle 
   stringDialog/string
  /property
  layout class=QVBoxLayout 
   item
widget class=QCheckBox name=kcfg_MyOption 
 property name=text 
  stringOption/string
 /property
/widget
   /item
   item
spacer
 

[PyQt] dbus and PyKDE

2008-03-27 Thread Jonathan Riddell

I'm trying to get a printer applet into KDE (see kde-core-devel),
however I can't actually use pyKDE because oxygen style and
KApplication load QtDbus which causes the application to freeze when
I'm using python-dbus.

For example this app freezes when using KApplication but not when
using QApplication.

http://kubuntu.org/~jriddell/tmp/minimal.py

Does anyone have any ideas on how to work around this?

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


[PyQt] Re: [PyKDE] KConfigSkeleton/KConfigDialog combo not working

2008-03-27 Thread Jim Bublitz
On Thursday 27 March 2008 08:32, Adeodato Simó wrote:
 Hello.

 I'm having trouble porting my PyKDE3 KConfigSkeleton/KConfigDialog: it
 behaves weird in KDE4.

 I'm attaching a very small sample program. The weird behavior I'm
 observing is:

   (a) on the first run, when no testrc file exists under ~/.kde, the
   value of MyOption is correctly set to False, but when I click on
   the Preferences button, the checkbox is checked (instead of not
   checked, at it'd correspond)

   (b) so I change in the dialog the value to True, when closing the
   dialog the LineEdit updates accordingly, and the option is written
   as true to the testrc file, but when I restart the program, it
   is set to False again

 Can you reproduce? Is there something wrong with my code? (With KDE 3 it
 worked just fine).

 Thanks in advance,

If you add some print statements you can see what's happening, but not why - 
haven't figured that out yet.

In Preferences.__init__(), the value is False after both the addItemBool and 
readConfig() calls. But on return from the Preferences() call in the main 
window __init__, the value is True. Obviously , that's not right.

Otherwise, I'm still looking into it.

Jim

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


[PyQt] Nullable foreign keys

2008-03-27 Thread Catriona Johnson
Hello

I have a QSqlRelationalTableModel which is viewed using a QTableView
and QSqlRelationalDelegate to give comboboxes for foreign key fields.

My question is how do I handle nullable foreign keys? If foreign key
is null it is not being displayed in the QTableView and there seems to
be no way of having a null value in a combo box apart from having a
'Null' record which I don't really want to do.

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