示例#1
0
	def OnInit(self):
		''' '''
		self.database = CQBDatabase.instance()

		try:
			profiles = list(self.database.profiles())
			dialog = wx.SingleChoiceDialog(None, "Select a Profile", "Cognac QueryBrowser", [x[5] for x in profiles])
			while True:
				if dialog.ShowModal() == wx.ID_OK:
					# get selected profile and destroy dialog
					profile = profiles[dialog.GetSelection()]
					break
				else:
					return False

			# pass connection to new instance of CQBFrame
			dialog.Destroy()
			con_params = {'id': profile[0], 'host': profile[1], 'user': profile[2], 'passwd': profile[3], 'port': profile[4], 'name': profile[5]}

			frame = CQB.getNewFrame(wx.ID_ANY, con_params=con_params)
			self.SetTopWindow(frame)
			return True

		except connection.errors.CQBConnectionError, exc:
			wx.MessageBox(str(exc), "Initial Connection Failed", wx.OK | wx.ICON_ERROR)
			return False
示例#2
0
	def loadProfile():
		''' '''
		database = CQBDatabase.instance()
		try:
			profiles = list(database.profiles())
			dialog = wx.SingleChoiceDialog(None, "Select a Profile", "Cognac Query Browser", [x[5] for x in profiles])
			while True:
				if dialog.ShowModal() == wx.ID_OK:
					# get selected profile and destroy dialog
					profile = profiles[dialog.GetSelection()]
					dialog.Destroy()

					# return profile connection parameters
					return {'id': profile[0], 'host': profile[1], 'user': profile[2], 'passwd': profile[3], 'port': profile[4], 'name': profile[5]}

		except connection.errors.CQBConnectionError, exc:
			wx.MessageBox(str(exc), "New Connection Failed", wx.OK | wx.ICON_ERROR)
			return False