Work on native gui design and install documentation
This commit is contained in:
@@ -2,6 +2,9 @@
|
||||
|
||||
"""
|
||||
|
||||
YMS native GUI.
|
||||
Runs as user SYSTEM with id=0
|
||||
|
||||
Configuration file located at ~/.config/ymsgui.conf:
|
||||
[DB]
|
||||
host = localhost
|
||||
@@ -31,7 +34,8 @@ cfg = {
|
||||
'cfgfile': '~/.config/ymsgui.conf',
|
||||
'host': 'localhost',
|
||||
'db': 'yms',
|
||||
'user': 'yms'
|
||||
'user': 'yms',
|
||||
'docpath': '/var/local/yms'
|
||||
}
|
||||
|
||||
class Frontend():
|
||||
@@ -73,13 +77,27 @@ class Frontend():
|
||||
Gtk.main()
|
||||
|
||||
def on_but_info_clicked(self, widget):
|
||||
|
||||
# Userlist
|
||||
sql = ("SELECT userid, login, displayname FROM user ORDER BY login")
|
||||
db.cur.execute(sql)
|
||||
for row in db.cur.fetchall():
|
||||
print(row)
|
||||
|
||||
def on_but_equip_detail_clicked(self, widget):
|
||||
self.stack['equipment'].set_visible_child(self.box['equip_detail'])
|
||||
|
||||
def on_but_equip_edit_clicked(self, widget):
|
||||
self.stack['equipment'].set_visible_child(self.box['equip_edit'])
|
||||
|
||||
def on_but_equip_save_clicked(self, widget):
|
||||
pass
|
||||
|
||||
def on_but_equip_cancel_clicked(self, widget):
|
||||
self.stack['equipment'].set_visible_child(self.box['equipment'])
|
||||
|
||||
def on_but_equip_cancel_clicked(self, widget):
|
||||
self.stack['equipment'].set_visible_child(self.box['equipment'])
|
||||
|
||||
def on_destroy(self, widget, data=None):
|
||||
Gtk.main_quit()
|
||||
|
||||
@@ -101,12 +119,14 @@ def create_config(cfgfile):
|
||||
# create inital config file
|
||||
with open(cfgfile, 'w') as fh:
|
||||
fh.write('[DB]\n')
|
||||
fh.write('host = localhost\n')
|
||||
fh.write('db = yms\n')
|
||||
fh.write('user = yms\n')
|
||||
fh.write('pass = geheim\n\n')
|
||||
fh.write('host = {}\n'.format(cfg['host']))
|
||||
fh.write('db = {}\n'.format(cfg['db']))
|
||||
fh.write('user = {}\n'.format(cfg['user']))
|
||||
fh.write('pass = changeme!\n\n')
|
||||
fh.write('[documents]\n')
|
||||
fh.write('basepath = /var/local/yms\n')
|
||||
fh.write('basepath = {}\n'.format(cfg['docpath']))
|
||||
# secure configuration
|
||||
os.chmod(cfgfile, 0o600)
|
||||
|
||||
if __name__ == "__main__":
|
||||
locale.setlocale(locale.LC_ALL, '')
|
||||
@@ -117,7 +137,11 @@ if __name__ == "__main__":
|
||||
cfgfile = os.path.expanduser(cfg['cfgfile'])
|
||||
if not config.read(cfgfile):
|
||||
create_config(cfgfile)
|
||||
messagebox(_("Configuration file not found"), title="YMS")
|
||||
messagebox(_("Configuration file '%s' not found.\n"
|
||||
"Default configuration has been created.\n"
|
||||
"Please edit that file according to your needs.\n\n"
|
||||
"Then restart this program."
|
||||
) % cfgfile, title="YMS")
|
||||
else:
|
||||
cfg['host'] = config.get('DB', 'host')
|
||||
cfg['db'] = config.get('DB', 'db')
|
||||
@@ -129,6 +153,10 @@ if __name__ == "__main__":
|
||||
app.run()
|
||||
db.disconnect()
|
||||
else:
|
||||
messagebox(_("Database connection cannot be established"), title="YMS")
|
||||
errno, errtxt = db.last_error()
|
||||
messagebox(_("Database connection cannot be established.\n\n"
|
||||
"Server: %s\nDatabase: %s\n"
|
||||
"Error: %s (%d)"
|
||||
) % (cfg['host'], cfg['db'], errtxt, errno), title="YMS")
|
||||
|
||||
# Another fine product of the sirius cybernetics corporation
|
||||
|
||||
Reference in New Issue
Block a user