書いているプログラムに問題があります。かなり大きくなるので、レイアウトやシグナルなどを別のクラス/モジュールに分けて、読みやすくしたいと思います。別のクラスからレイアウト ウィジェットを編集できるようにしたいと考えています。これは可能ですか、それとも不可能なことをしようとしていますか? 私の説明が明確でない場合に備えて、以下に例を含めました
class Layout:
def __init__(self):
self.callback = CallBack()
def Gui(self):
'''
some layout with a listwidget that affects another listwidget depending on choice for example
'''
self.list1 = QtGui.QListWidget()
self.list1.addItems(['chocolate', 'candy', 'pop'])
self.list1.itemClicked.connect(self.callback.ButtonCallback)
self.list2 = QtGui.QListWidget()
class CallBack(Layout):
def __init__(self)
super(CallBack, self).__init__()
def ButtonCallback(self, button_signal):
'''
do get options for self.list2 depending on chosen item
'''
new_items = ['item1', 'item2', 'item3']
Layout.list2.addItems(new_items)
コードの最後の行はおそらく間違っていると思いますが、それは私が苦労している部分です。
助けてくれてありがとう。