I am writing a Tkinter script, but I have reached an error. When I run my script, all my buttons are quite small and don't act correctly. For example, one of my buttons is supposed to open a file dialogue, but instead, it returns the error code:
X Error of failed request: BadAlloc (insufficient resources for operation)
Major opcode of failed request: 53 (X_CreatePixmap)
Serial number of failed request: 4750
Current serial number in output stream: 4769
However, when I ran my code on a Windows machine instead of my Linux (Ubuntu) machine, it worked fine.
Here is my code:
import qrtools
from Tkinter import *
from tkFileDialog import *
class Decode:
def __init__(self,master):
self.l = StringVar()
self.master = master
self.frame = Frame(self.master)
self.browse = Button(master,text="Choose a File:", command = self.filenameget).pack()
self.label = Label(master)
self.label.pack()
self.dcode = Button(master,text = "You Haven't Chosen A File Yet!")
self.dcode.pack()
self.dcodedata = Label(master)
self.dcodedata.pack()
self.quitbutt = Button(master, text = 'Back To Main Page',command = self.q).pack()
def q(self):
import subprocess
subprocess.check_call(['python2.7','start.py'])
quit()
def filenameget(self):
t = askopenfilename()
print t
self.label.config(text = t)
self.dcode.config(text = 'Decode', command = self.get_decode)
def get_decode(self):
qr = qrtools.QR()
qr.decode(str(self.label.cget("text")))
self.dcodedata.config(text=str(qr.data))
def main():
root = Tk()
dc = Decode(root)
root.title = "Qr Decoder By: Brian Ton"
root.mainloop()
if __name__ == '__main__':
main()
In addition, I tried to run a much simpler program, but to still no avail.
Here is the code to the simple program:
from Tkinter import *
master = Tk()
def print_test():
print 'Hello'
button = Button(master, text = "Test Button", command = print_test)
button.pack()
mainloop()
My main questions are:
- Is this an Ubuntu Issue?
- If so, is there a workaround?
If you want to look at some screenshots, they are also attached.
Ubuntu Qr Decoder
Windows Qr Decoder
Simple Program on Ubuntu
Simple Program on Windows