Ask Ubuntu is a question and answer site for Ubuntu users and developers. It's 100% free.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I'm really puzzled by this, but the answer is probably quite simple and just can't see it:

I have a series of python modules that work fine from within the python interpreter, but nothing happens when running from a GUI situation. I've tried creating a .desktop file, adding shebangs, changing permissions to 777 and renaming to .pyw for all the modules. A single test module works fine on its own, so I know that it's not a typo error.

If I click the main module .pyw file and click 'Run' from the system dialogue nothing happens at all. Similarly the .py file (and the .desktop via menu), nothing happens. Here is the start of my code:


import tkinter as tk, imp, sys

root = tk.Tk()
msg = tk.messagebox
sdg = tk.simpledialog

import capitaliser_cfg as cfg, fileio as io
imp.reload(cfg) ; imp.reload(io) 

# Nb: attach to config for simplicity
cfg.counties = io.getfilelist("counties.txt", "London")

if not type(cfg.counties)==list:
    k = msg.showerror(cfg.version, cfg.counties)

cfg.tempdict = [[],[],[]]
cfg.spelldict = io.getdictionary("addressdict.txt","roda","Road")
if not type(cfg.spelldict)==dict:
    k = msg.showerror(cfg.version, cfg.spelldict)

import thinbutton as tb, labelradio as lr, fieldblock as fb, bigbutton as bb 
import textblock as tx, padding as pd, widget_tools as wt
import capitaliser_mth as mth
import capitaliser_bnd as bnd

imp.reload(tb) ; imp.reload(lr) ; imp.reload(fb) ; imp.reload(bb)
imp.reload(tx) ; imp.reload(pd) ; imp.reload(wt) ;

If I put k = msg.showerror("xxxx","yyyy") after the line sdg = tk.simpledialog, stil nothing happens which leads me to believe that tkinter is not loading for some reason.

Any ideas anyone ?

share|improve this question
@ Corvus. Add the solution as a answer. So others can get benefit. When searching, Most people open the question only if it was marked as an answered question. (with Green icon) – user224082 Nov 19 '13 at 16:44
up vote 1 down vote accepted

Solution kindly supplied on Stackoverflow board by Furas:

For Python 2 try:

import tkMessageBox
import tkSimpleDialog

msg = tkMessageBox
sdg = tkSimpleDialog

or simpler:

import tkMessageBox as msg
import tkSimpleDialog as sdk

For Python 3 try:

from tkinter import messagebox
from tkinter import simpledialog

msg = messagebox
sdg = simpledialog

or simpler:

from tkinter import messagebox as msg
from tkinter import simpledialog as sdg

** I used the last 2 lines and it works perfectly now..

share|improve this answer
What a suprise. My answer on AskUbuntu :) – furas May 3 '14 at 2:08

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.