easygui buttonbox crashes becase of default font from Tkinter - python

I'm using easygui in a Python app and then generate an .exe with PyInstaller.
Everything works fine in my computer, but my colleague get this weird error when they try to run the app :
Traceback (most recent call last):
File "easygui\boxes\button_box.py", line 95, in buttonbox
File "easygui\boxes\button_box.py", line 147, in __init__
File "easygui\boxes\button_box.py", line 268, in __init__
File "tkinter\font.py", line 23, in nametofont
File "tkinter\font.py", line 86, in __init__
RuntimeError: main thread is not in main loop
The line where easygui is called is simply
choice = easygui.buttonbox(
"msg", "title", choices=["choice1", "choice2"],
default_choice="choice1", cancel_choice="choice2"
)
so the problem seems to be with the font but I'm not using anything particular in easygui ? I've searched for issues on the easygui's Git but couldn't find anything
Also, there was another easygui.buttonbox earlier in the process but this one did show up properly so I'm just really confused.
Thanks!

The solution was to show the msgbox in the main thread. It crashed because the msgbx was in a different thread than the main one

Related

Did pyglet change recently?

So, The other day, I went back to an old project to finish it but when I tried running it, it gave me several errors that I've tried to fix but some of them I don't know how to fix. The program worked fine when I stopped working on it, so I'm very confused at what happened. My guess is that pyglet got a new update and removed a lot of stuff I used to use. Some of the errors I get are as follows
Traceback (most recent call last):
File "C:\Users\____\Desktop\Code\3D\Projects\3D Program 1\main.py", line 9,
in <module>
screen =
pyglet.window.get_platform().get_default_display().get_default_screen()
AttributeError: module 'pyglet.window' has no attribute 'get_platform'
and
Traceback (most recent call last):
File "C:\Users\____\Desktop\Code\3D\Projects\3D Program 1\main.py", line 216, in <module>
main()
File "C:\Users\____\Desktop\Code\3D\Projects\3D Program 1\main.py", line 208, in main
win = Window(caption = "3D Program 1", width = WINW, height = WINH, resizable = False, vsync = True)
File "C:\Users\____\Desktop\Code\3D\Projects\3D Program 1\main.py", line 57, in __init__
self.tex1 = get_tex("steel_tex.png")
File "C:\Users\____\Desktop\Code\3D\Projects\3D Program 1\main.py", line 21, in get_tex
tex = pyglet.image.load(file).texture
AttributeError: 'ImageData' object has no attribute 'texture'
I also had problems with it saying that there was no such thing as the "pyglet.graphics.TextureGroup" class
Yes, it looks like both of snippets of code you show are using features that were deprecated in previous versions of Pyglet and removed in the recent 1.4 release. You can see the deprecation (and their suggested replacements) in the documentation for older versions:
The get_platform() function in pyglet.window:
Deprecated. Use pyglet.canvas.Display.
The .texture attribute of an image:
Deprecated. Use get_texture().

Tweepy issues with twitter bot and python

I have a few twitterbots that I run on my raspberryPi. I have most functions wrapped in a try / except to ensure that if something errors it doesn't break the program and continues to execute.
I'm also using Python's Streaming library as my source of monitoring for the tags that I want the bot to retweet.
Here is an issue that happens that kills the program although I have the main function wrapped in a try/except:
Unhandled exception in thread started by <function startBot5 at 0x762fbed0>
Traceback (most recent call last):
File "TwitButter.py", line 151, in startBot5
'<botnamehere>'
File "/home/pi/twitter/bots/TwitBot.py", line 49, in __init__
self.startFiltering(trackList)
File "/home/pi/twitter/bots/TwitBot.py", line 54, in startFiltering
self.myStream.filter(track=tList)
File "/usr/local/lib/python3.4/dist-packages/tweepy/streaming.py", line 445, in filter
self._start(async)
File "/usr/local/lib/python3.4/dist-packages/tweepy/streaming.py", line 361, in _start
self._run()
File "/usr/local/lib/python3.4/dist-packages/tweepy/streaming.py", line 294, in _run
raise exception
File "/usr/local/lib/python3.4/dist-packages/tweepy/streaming.py", line 263, in _run
self._read_loop(resp)
File "/usr/local/lib/python3.4/dist-packages/tweepy/streaming.py", line 313, in _read_loop
line = buf.read_line().strip()
AttributeError: 'NoneType' object has no attribute 'strip'
My setup:
I have a parent class TwitButter.py, that creates an object from the TwitBot.py. These objects are the bots, and they are started on their own thread so they can run independently.
I have a function in the TwitBot that runs the startFiltering() function. It is wrapped in a try/except, but my except code is never triggered.
My guess is that the error is occurring within the Streaming library. Maybe that library is poorly coded and breaks on the line that is specified at the bottom of the traceback.
Any help would be awesome, and I wonder if others have experienced this issue?
I can provide extra details if needed.
Thanks!!!
This actually is problem in tweepy that was fixed by github #870 in 2017-04. So, should be resolved by updating your local copy to latest master.
What I did to discover that:
Did a web search to find the tweepy source repo.
Looked at streaming.py for context on the last traceback lines.
Noticed the most recent change to the file was the same problem.
I'll also note that most of the time you get a traceback from deep inside a Python library, the problem comes from the code calling it incorrectly, rather than a bug in the library. But not always. :)

multiprocessing in iPython: too many files open when I'm not opening any files?

I have an IPython notebook that I was running as multi-threaded and have changed over to try and run on multiple processors. There is a substantial amount of code that I won't quote here unless someone thinks it would be helpful to look at a specific portion of it. The gist of it is that I'm trying to wrap a load balancer around PyOpenCL so I need to feed multiple independent queues-- partly to solve a specific problem (particle simulation) and partly as a learning exercise.
At no point am I intentionally opening any files, yet it's crashing with this error:
Traceback (most recent call last):
File "//anaconda/lib/python3.4/site-packages/IPython/core/interactiveshell.py", line 3035, in run_code
File "<ipython-input-23-d29c87aba720>", line 1, in <module>
co.convergeStep(mags[3])
File "<ipython-input-17-0eac43f0bbbf>", line 62, in convergeStep
evt=self.nlb.qTask(evtList,(b,k),b.forces,k,out=b.forceAccum,out2=k.forceAccum,sum=True)
File "<ipython-input-13-0f26b8ae660e>", line 36, in qTask
t=StagingThread(waitlist,c,self.pool)
File "<ipython-input-10-549b980aea87>", line 7, in __init__
self.killme=mp.Event()
File "//anaconda/lib/python3.4/multiprocessing/context.py", line 91, in Event
File "//anaconda/lib/python3.4/multiprocessing/synchronize.py", line 336, in __init__
File "//anaconda/lib/python3.4/multiprocessing/context.py", line 76, in Condition
File "//anaconda/lib/python3.4/multiprocessing/synchronize.py", line 215, in __init__
File "//anaconda/lib/python3.4/multiprocessing/context.py", line 81, in Semaphore
File "//anaconda/lib/python3.4/multiprocessing/synchronize.py", line 127, in __init__
File "//anaconda/lib/python3.4/multiprocessing/synchronize.py", line 60, in
__init__ OSError: [Errno 24] Too many open files
Is there something opening files in the background that I'm not considering?
It looks like I have 11 processes spawned at the time of failure. I'm running under OS X 10.10.3, Python 3.4.3, IPython 3.1. I am not using multiprocessing.Pool (at least not intentionally). It looks like the failure is happening in Event? There are other exceptions that occur while handling this one, but they're mostly too many files errors and then some traceback failures and other things that look like they're a result of one of the above...

RuntimeError: main thread is not in main loop while using tkinter.simpledialog

Here is my code:
import threading
import tkinter.simpledialog
def showDialog(evt):
dlg = tkinter.simpledialog.SimpleDialog(root,text='Test!', buttons=['OK'])
dlg.go()
def test():
threading.Thread(target=root.event_generate, args=('<<showDialog>>',)).start()
root = tkinter.Tk()
root.bind('<<showDialog>>',showDialog)
tkinter.Button(text = 'showDialog',command = test).pack()
root.mainloop()
I run this code with Python3.4
The First time I click showDialog Button it work perfectly
but if I press OK and click the button again,it raise a RuntimeError:
Exception in thread Thread-2:
Traceback (most recent call last):
File "D:\Program Files\Python34\lib\threading.py", line 921, in _bootstrap_inner
self.run()
File "D:\Program Files\Python34\lib\threading.py", line 869, in run
self._target(*self._args, **self._kwargs)
File "D:\Program Files\Python34\lib\tkinter\__init__.py", line 1501, in event_generate
self.tk.call(args)
RuntimeError: main thread is not in main loop
I'm learning python recently,this code is just a demo.I want to do some work after press the button in sub-thread,because it will cost a few second and I don't want to stuck the UI. When the work is done,it will show a dialog.?
Can someone please tell me how can I do this using tkinter and why this problem occur?
Thanks!And sorry for my poor English.
Mixing threads with GUIs, and in particular tk, is tricky. I do not know all the rules, but unpredictable exceptions and deadlocks are two of the problems. I am a bit surprised that generating an event in a separate thread from the main thread and mainloop worked even once. (Why are you trying that?) A simplified function that run in the same thread does work consistently.
def test():
root.event_generate('<<showDialog>>')

Vlc python binding - ctype error

I am trying to run the example file provided here : http://git.videolan.org/?p=vlc/bindings/python.git;a=tree;f=examples;hb=HEAD (the qtvlc example).
It gives me the following error :
$>c:\Python27_32b\python.exe examples_qtvlc.py "test_file.mov"
Traceback (most recent call last):
File "examples_qtvlc.py", line 114, in PlayPause
self.OpenFile()
File "examples_qtvlc.py", line 153, in OpenFile
self.MediaPlayer.set_hwnd(self.VideoFrame.winId())
File "vlc.py", line 2126, in set_hwnd
return libvlc_media_player_set_hwnd(self, drawable)
File "vlc.py", line 4263, in libvlc_media_player_set_hwnd
return f(p_mi, drawable)
ctypes.ArgumentError: argument 2: <type 'exceptions.TypeError'>: wrong type
Traceback (most recent call last):
File "examples_qtvlc.py", line 192, in <module>
sys.exit(app.exec_())
It doesn't give me the error when I run the program, it gives it when I choose a .mov file from the "play" button in the interface.
Btw, if I try to play an .avi file it plays it, but in another window and it gives a "No accelerated IMDCT transform found".
The thing is I really need to be able to play .mov files, it is the only reason I am using the vlc module instead of Phonon available with PyQt.
I was having the same error when I tried to use the vlc module in my code so I thought I was doing something wrong. But if the example file is not working I guess there is something wrong in my config rather than my code. What can cause this error ?
EDIT :
I didn't notice, but if i click "play" again after choosing the file (and getting the error), the file does play... outside of the window.. The problem is that I don't have any control in this new window where the video plays.. What do I have to do to get it to play inside the application ?
The second thing is that I get the following error (repeating as the video plays)
[075e5654] main subpicture error: blending YUVA to J422 failed
I don't know if it important or not ...
SOLVED :
For those who would be interested, I casted the
self.VideoFrame.winId()
as an int and it seems to be doing what I want
Thanks for those who took the time to read this question..

Categories

Resources