I'm trying to get some text to display on the GUI window, I can get it to print to the console. Here is my sample code, I think I'm close but seem to be missing something simple. The section in bold is where I'm trying to get the text to display on the window when the button <b>pushButtonHarvest</b> is pushed.<br>
<br><blockquote style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;" class="gmail_quote">#!/usr/lib/python<br>import sys, random, sqlite3, os<br>from PyQt4 import QtGui, QtCore<br>
from geodesic import Ui_MainWindow<br><br># A new class here<br># derived from QMainWindow<br>class TestApp(QtGui.QMainWindow):<br> def __init__(self):<br> QtGui.QMainWindow.__init__(self)<br> self.ui = Ui_MainWindow()<br>
self.ui.setupUi(self)<br><br># -- Create the DB connection -- #<br>database_name = "rpg.db"<br>if not os.path.isfile(database_name):<br> print ("Creating RPG module")<br>db_connection = sqlite3.connect(database_name)<br>
db_cursor = db_connection.cursor()<br>try:<br> db_cursor.execute("""CREATE TABLE Skills (id INTEGER PRIMARY KEY AUTOINCREMENT, skill TEXT, value TEXT)""")<br> db_cursor.execute ("INSERT INTO Skills (skill, value) VALUES ('Harvesting', '0.00')")<br>
db_cursor.execute ("INSERT INTO Skills (skill, value) VALUES ('Boyer', '0.00')")<br> db_cursor.execute ("INSERT INTO Skills (skill, value) VALUES ('Herbalism', '0.00')")<br>
db_cursor.execute ("INSERT INTO Skills (skill, value) VALUES ('Mining', '0.00')")<br> db_connection.commit()<br> db_connection.close()<br>except sqlite3.OperationalError:<br> print ("Connecting to Geodesic.")<br>
<br># -- Start building the skills -- #<br>class Skills:<br> harvest = "Harvesting."<br> boyer = "Boyer."<br> herbalism = "Herbalism."<br> mining = "Mining."<br> def gainMessage(self):<br>
return "You have gained"<br> def rollPoint(self):<br> return random.uniform(0.1,0.2)<br> <br><b>class useHarvest(TestApp, Ui_MainWindow, Skills):<br> def __init__(self, text, parent=None):<br>
super(useHarvest, self).__init__(parent)<br> useSkill = Skills()<br> self.pushButtonHarvest.setEnabled(enable)<br> self.emit(SIGNAL(useSkill.gainMessage(), ('%.2f' % useSkill.rollPoint()), "in", useSkill.harvest))<br>
self.ui.setupUi(self)</b><br> <br>if __name__ == "__main__":<br> app = QtGui.QApplication(sys.argv)<br> window = TestApp()<br> window.show()<br> sys.exit(app.exec_())<br></blockquote>