开发者

How to make pyuic4 automatically set tabs to "MainWindow"?

开发者 https://www.devze.com 2022-12-18 01:01 出处:网络
After adding a new label and textEdit to a grid right above these tabs, When I generate the ui.py file with pyuic4, It generates the the following lines for many different tabs which gives errors abou

After adding a new label and textEdit to a grid right above these tabs, When I generate the ui.py file with pyuic4, It generates the the following lines for many different tabs which gives errors about not having enough arguments.

self.tcTab.setTabText(self.tcTab.indexOf(self.tab_6),) 

However the .ui would generate this fine before I made the changes.

self.tcTab.setTabText(self.tcTab.indexOf(self.tab_6), QtGui.QApplication.translate("MainWindow", " ", None, QtGui.QApplication.UnicodeUTF8))

This code works fine, and If I edit this into the ui.py file my changes also work fine. However how do I get it to automatically do this when i use pyuic4. Because from what I understand is that you should never have to edit the ui.py file. Thanks

Edited: I updated everything to no avail. pretty much any change I do to old UI file will cause this problem if I use pyuic4 on it. translatable IS checked under currentTabText in qtDesigner if that matters. The problem happens in this function of the .py file:

def retranslateUi(self, MainWindow):

    #these are incorrect ones pyuic4 generates
    self.tcTab.setTabText(self.tcTab.indexOf(self.tab_6), )
    self.tcTab.setTabText(self.tcTab.indexOf(self.tab_9), )

    #these are the correct lines it used to generate
   self.tcTab.setTabText(self.tcTab.indexOf(self.tab_6),QtGui.QApplication.translate("MainWinow", " ", None, QtGui.QApplication.UnicodeUTF8))
   s开发者_C百科elf.tcTab.setTabText(self.tcTab.indexOf(self.tab_9), QtGui.QApplication.translate("MainWindow", " ", None, QtGui.QApplication.UnicodeUTF8))

Edit2: Even when I open the .ui up in qtdesigner, click something, without even modifying it, save, then use pyuic4, it generates the bad code.


YAY!!!!

The setTabText field for tabs when using designer must have something in it. It turns out the ui was using white spaces as the tabText, whenever you open designer it got rid of the white spaces. So if you set the tab text to a space again after making your changes it works.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号