jondecker76
March 9th, 2012, 06:55 PM
Hello
I have many years of programming experience, though I'm new to glade, python and gtkbuilder. I'm trying to do some simple tests working towards completing a gimp plugin for my wife's photography business. While I normally research and learn on my own, I can't find any decent examples anywhere using python glade and gtkbuilder together. Here is a simple example where I want to display a simple messageDialog. I have no problem defining it in glade, nor getting it to show up on the screen.. However, I can't for the life of me figure out how to set the text or secondary text of the dialog - so it just sits there blank :(
What am I doing wrong?
#! /usr/bin/env python
#import gimpplugin
import time
# UI Includes
import sys
try:
import gtk
except:
sys.exit(1)
import pygtk # Do I even need pygtk, or is the gtk import above enough??
# Logging stuff...
import logging
logger = logging.getLogger('myapp')
hdlr = logging.FileHandler('test.log',mode="wb")
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.INFO)
#UI Class
class UI():
def __init__(self):
self.gladefile = "DPplugin.glade"
self.builder=gtk.Builder()
self.builder.add_from_file(self.gladefile)
self.builder.connect_signals(self)
return
def InfoDialog(self,title,message):
self.infoMessageDialog=self.builder.get_object("infoMessageDialog")
self.infoMessageDialog.text=title ###<- WHY WONT THIS WORK??
self.infoMessageDialog.show_all()
return
#class myplugin(gimpplugin.plugin):
class myplugin():
def init(self):
# initialisation routines
# called when gimp starts.
logger.info('Plugin initializing...')
# Set the glade file
self.UI=UI()
return
def quit(self):
# clean up routines
# called when gimp exits (normally).
logger.info('Plugin deinitializing...')
self.UI.InfoDialog(self,"hi")
# Needed by all GTK programs
gtk.main()
time.sleep(10)
return
def query(self):
# called to find what functionality the plugin provides.
#gimp.install_procedure("procname", ...)
return
# note that this method name matches the first arg of
# gimp.install_procedure
#def procname(self, arg1, ...):
def procname(self):
# do what ever this plugin should do
return
blah=myplugin()
blah.init()
blah.quit()
Please ignore the messy code, I'm just trying some simple tests to learn some things...
thanks for any help!
I have many years of programming experience, though I'm new to glade, python and gtkbuilder. I'm trying to do some simple tests working towards completing a gimp plugin for my wife's photography business. While I normally research and learn on my own, I can't find any decent examples anywhere using python glade and gtkbuilder together. Here is a simple example where I want to display a simple messageDialog. I have no problem defining it in glade, nor getting it to show up on the screen.. However, I can't for the life of me figure out how to set the text or secondary text of the dialog - so it just sits there blank :(
What am I doing wrong?
#! /usr/bin/env python
#import gimpplugin
import time
# UI Includes
import sys
try:
import gtk
except:
sys.exit(1)
import pygtk # Do I even need pygtk, or is the gtk import above enough??
# Logging stuff...
import logging
logger = logging.getLogger('myapp')
hdlr = logging.FileHandler('test.log',mode="wb")
formatter = logging.Formatter('%(asctime)s %(levelname)s %(message)s')
hdlr.setFormatter(formatter)
logger.addHandler(hdlr)
logger.setLevel(logging.INFO)
#UI Class
class UI():
def __init__(self):
self.gladefile = "DPplugin.glade"
self.builder=gtk.Builder()
self.builder.add_from_file(self.gladefile)
self.builder.connect_signals(self)
return
def InfoDialog(self,title,message):
self.infoMessageDialog=self.builder.get_object("infoMessageDialog")
self.infoMessageDialog.text=title ###<- WHY WONT THIS WORK??
self.infoMessageDialog.show_all()
return
#class myplugin(gimpplugin.plugin):
class myplugin():
def init(self):
# initialisation routines
# called when gimp starts.
logger.info('Plugin initializing...')
# Set the glade file
self.UI=UI()
return
def quit(self):
# clean up routines
# called when gimp exits (normally).
logger.info('Plugin deinitializing...')
self.UI.InfoDialog(self,"hi")
# Needed by all GTK programs
gtk.main()
time.sleep(10)
return
def query(self):
# called to find what functionality the plugin provides.
#gimp.install_procedure("procname", ...)
return
# note that this method name matches the first arg of
# gimp.install_procedure
#def procname(self, arg1, ...):
def procname(self):
# do what ever this plugin should do
return
blah=myplugin()
blah.init()
blah.quit()
Please ignore the messy code, I'm just trying some simple tests to learn some things...
thanks for any help!