コード例 #1
0
ファイル: gmATCWidgets.py プロジェクト: ncqgm/gnumed
def update_atc_reference_data():

	dlg = wx.FileDialog (
		parent = None,
		message = _('Choose an ATC import config file'),
		defaultDir = os.path.expanduser(os.path.join('~', 'gnumed')),
		defaultFile = '',
		wildcard = "%s (*.conf)|*.conf|%s (*)|*" % (_('config files'), _('all files')),
		style = wx.FD_OPEN | wx.FD_FILE_MUST_EXIST
	)

	result = dlg.ShowModal()
	if result == wx.ID_CANCEL:
		return

	cfg_file = dlg.GetPath()
	dlg.DestroyLater()

	conn = gmAuthWidgets.get_dbowner_connection(procedure = _('importing ATC reference data'))
	if conn is None:
		return False

	wx.BeginBusyCursor()

	if gmATC.atc_import(cfg_fname = cfg_file, conn = conn):
		gmDispatcher.send(signal = 'statustext', msg = _('Successfully imported ATC reference data.'))
	else:
		gmDispatcher.send(signal = 'statustext', msg = _('Importing ATC reference data failed.'), beep = True)

	wx.EndBusyCursor()
	return True
コード例 #2
0
def update_atc_reference_data():

    dlg = wx.FileDialog(parent=None,
                        message=_('Choose an ATC import config file'),
                        defaultDir=os.path.expanduser(
                            os.path.join('~', 'gnumed')),
                        defaultFile='',
                        wildcard="%s (*.conf)|*.conf|%s (*)|*" %
                        (_('config files'), _('all files')),
                        style=wx.FD_OPEN | wx.FD_FILE_MUST_EXIST)

    result = dlg.ShowModal()
    if result == wx.ID_CANCEL:
        return

    cfg_file = dlg.GetPath()
    dlg.DestroyLater()

    conn = gmAuthWidgets.get_dbowner_connection(
        procedure=_('importing ATC reference data'))
    if conn is None:
        return False

    wx.BeginBusyCursor()

    if gmATC.atc_import(cfg_fname=cfg_file, conn=conn):
        gmDispatcher.send(signal='statustext',
                          msg=_('Successfully imported ATC reference data.'))
    else:
        gmDispatcher.send(signal='statustext',
                          msg=_('Importing ATC reference data failed.'),
                          beep=True)

    wx.EndBusyCursor()
    return True