mirror of
https://github.com/gryf/pygtktalog.git
synced 2025-12-17 19:40:21 +01:00
* Refactored Qst dialog class - it has not been returned anything.
* Added dialog for entering name of a top-most element in katalog.
This commit is contained in:
41
dialogs.py
41
dialogs.py
@@ -5,29 +5,25 @@ import gtk
|
|||||||
|
|
||||||
class Qst:
|
class Qst:
|
||||||
"""Show simple dialog for questions"""
|
"""Show simple dialog for questions"""
|
||||||
def __init__(self, win = None, title="", message=""):
|
def __init__(self, title="", message=""):
|
||||||
self.dialog = gtk.MessageDialog(
|
self.dialog = gtk.MessageDialog(
|
||||||
parent = None,
|
|
||||||
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||||
type = gtk.MESSAGE_QUESTION,
|
type = gtk.MESSAGE_QUESTION,
|
||||||
buttons = gtk.BUTTONS_OK_CANCEL,
|
buttons = gtk.BUTTONS_OK_CANCEL,
|
||||||
)
|
)
|
||||||
self.dialog.set_title(title)
|
self.dialog.set_title(title)
|
||||||
self.dialog.set_markup(message)
|
self.dialog.set_markup(message)
|
||||||
self.dialog.connect('response', lambda dialog, response: self.ret(response))
|
def run(self):
|
||||||
self.dialog.show()
|
retval = self.dialog.run()
|
||||||
def ret(self,result):
|
|
||||||
self.dialog.destroy()
|
self.dialog.destroy()
|
||||||
if result == gtk.RESPONSE_OK:
|
if retval == gtk.RESPONSE_OK:
|
||||||
return True
|
return True
|
||||||
else:
|
|
||||||
return False
|
return False
|
||||||
|
|
||||||
class Inf:
|
class Inf:
|
||||||
"""Show simple dialog for notices"""
|
"""Show simple dialog for notices"""
|
||||||
def __init__(self, win = None, title="", message=""):
|
def __init__(self, title="", message=""):
|
||||||
self.dialog = gtk.MessageDialog(
|
self.dialog = gtk.MessageDialog(
|
||||||
parent = None,
|
|
||||||
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||||
type = gtk.MESSAGE_INFO,
|
type = gtk.MESSAGE_INFO,
|
||||||
buttons = gtk.BUTTONS_OK,
|
buttons = gtk.BUTTONS_OK,
|
||||||
@@ -42,9 +38,8 @@ class Inf:
|
|||||||
|
|
||||||
class Wrn:
|
class Wrn:
|
||||||
"""Show simple dialog for warnings"""
|
"""Show simple dialog for warnings"""
|
||||||
def __init__(self, win = None, title="", message=""):
|
def __init__(self, title="", message=""):
|
||||||
self.dialog = gtk.MessageDialog(
|
self.dialog = gtk.MessageDialog(
|
||||||
parent = None,
|
|
||||||
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||||
type = gtk.MESSAGE_WARNING,
|
type = gtk.MESSAGE_WARNING,
|
||||||
buttons = gtk.BUTTONS_CLOSE,
|
buttons = gtk.BUTTONS_CLOSE,
|
||||||
@@ -59,9 +54,8 @@ class Wrn:
|
|||||||
|
|
||||||
class Err:
|
class Err:
|
||||||
"""Show simple dialog for errors"""
|
"""Show simple dialog for errors"""
|
||||||
def __init__(self, win = None, title="", message=""):
|
def __init__(self, title="", message=""):
|
||||||
self.dialog = gtk.MessageDialog(
|
self.dialog = gtk.MessageDialog(
|
||||||
parent = None,
|
|
||||||
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
flags = gtk.DIALOG_DESTROY_WITH_PARENT,
|
||||||
type = gtk.MESSAGE_ERROR,
|
type = gtk.MESSAGE_ERROR,
|
||||||
buttons = gtk.BUTTONS_CLOSE,
|
buttons = gtk.BUTTONS_CLOSE,
|
||||||
@@ -74,7 +68,7 @@ class Err:
|
|||||||
self.dialog.destroy()
|
self.dialog.destroy()
|
||||||
return True
|
return True
|
||||||
|
|
||||||
class About:
|
class Abt:
|
||||||
"""Show simple dialog for errors"""
|
"""Show simple dialog for errors"""
|
||||||
def __init__(self, name=None, ver="", title="", authors=[],licence=""):
|
def __init__(self, name=None, ver="", title="", authors=[],licence=""):
|
||||||
self.dialog = gtk.AboutDialog()
|
self.dialog = gtk.AboutDialog()
|
||||||
@@ -86,3 +80,22 @@ class About:
|
|||||||
self.dialog.connect('response', lambda dialog, response: self.dialog.destroy())
|
self.dialog.connect('response', lambda dialog, response: self.dialog.destroy())
|
||||||
self.dialog.show()
|
self.dialog.show()
|
||||||
|
|
||||||
|
class InputDiskLabel:
|
||||||
|
"""Sepcific dialog for quering user for a disc label""" #{{{
|
||||||
|
def __init__(self, label=""):
|
||||||
|
self.gladefile = "glade/dialogs.glade"
|
||||||
|
self.label = ""
|
||||||
|
if label!= None:
|
||||||
|
self.label = label
|
||||||
|
|
||||||
|
def run(self):
|
||||||
|
gladexml = gtk.glade.XML(self.gladefile, "inputDialog")
|
||||||
|
dialog = gladexml.get_widget("inputDialog")
|
||||||
|
entry = gladexml.get_widget("volname")
|
||||||
|
entry.set_text(self.label)
|
||||||
|
result = dialog.run()
|
||||||
|
dialog.destroy()
|
||||||
|
if result == gtk.RESPONSE_OK:
|
||||||
|
return entry.get_text()
|
||||||
|
return None
|
||||||
|
#}}}
|
||||||
|
|||||||
Reference in New Issue
Block a user