Installing wxPython in Ubuntu 12.10 - python

I am trying to install wxPython on my Ubuntu 12.10 but with no success. I have gone through all the answers given on this website.
Can someone please help me in this or point me in the right direction.
Initially, I tried http://wxpython.org/BUILD.html but then I came to know that it is in the repository, I ran "sudo apt-get install install python-wxgtk2.8", it installed without any error but then, when I run it, it is still unavailable. I guess I am doing something in the running step.
Also, although it is working in Eclipse using PyDev, but I am getting this warning " LIBDBUSMENU-GLIB-WARNING **: Trying to remove a child that doesn't believe we're it's parent."" after I close the application and the status bar is also not working,
Here is my code:
import wx
class naman(wx.Frame):
def __init__(self,parent,id): # #ReservedAssignment
wx.Frame.__init__(self,parent,id,'Frame aka Window', size=(300,200))
panel=wx.Panel(self)
statusbar=self.CreateStatusBar()
menubar=wx.MenuBar()
first=wx.Menu()
second=wx.Menu()
first.Append(wx.NewId(),"New Window", "This opens a new window")
first.Append(wx.NewId(),"Open...", "This will open")
second.Append(wx.NewId(),"Undo", "This will undo")
second.Append(wx.NewId(),"Redo", "This will redo")
menubar.Append(first,"File")
menubar.Append(second,"Edit")
self.SetMenuBar(menubar)
if __name__=='__main__':
app=wx.PySimpleApp()
frame=naman(parent=None,id=-1)
frame.Show()
app.MainLoop()
If someone can tell why I am getting this warning and why status bar is not working, that would be great too!! Then, I can continue working in eclipse itself and don't bother about wxPython.
PS: I have Python2.7 and Python3.3 already installed.
Thanks in advance.

You need to install wxPython Phoenix, not 2.8. The 2.8 series and the 2.9 Classic series are only Python 2.x compatible. You'll have to grab a Phoenix snapshot to build against as it is the only version that is Python 3 compatible. You can get one here:
http://wxpython.org/Phoenix/snapshot-builds/
Note that Phoenix is very beta in that it only supports the core widgets currently. Most of the custom widgets, like those in wx.lib, are still being ported. See http://wiki.wxpython.org/ProjectPhoenix for more information.

Related

`tkinter._test()` buttons are invisible when using pipenv

I'm learning Tkinter right now and trying to work through my first issue, but finding Google hasn't been helpful.
I'm running this code on Mac OS X 10.15.1 (Catalina)
I'm using Python 3.7 and my code looks like so (lots of boilerplate per PEP8 standards):
"""
Experiments in tkinter
"""
import tkinter as tk
def main():
"""
Main entrypoint
"""
tk._test()
if __name__ == "__main__":
main()
This outputs the following warning to the console:
DEPRECATION WARNING: The system version of Tk is deprecated and may be removed in a future release. Please don't rely on it. Set TK_SILENCE_DEPRECATION=1 to suppress this warning.
It also displays a window with completely blank buttons:
From my understanding these buttons should say "Click Me" and "Quit".
Also when I click on the top button it flashes black for a second like so:
After which the button is wider than before:
I assume the Tk version error may be related to the output behavior. However I can't seem to find a way to update Tk. What should I do here?
Update
After seeing #ShayneLoyd's answer (suggesting I needed an updated version of Python with an updated version of Tk) I began looking around some more and found this post on the Apple Discussion Boards which suggests you can use homebrew to install a version of Python which link's homebrew's own installed version of Tk. I tried this and it failed, so I Google'd the issue and found this StackOverflow post which seemed to suggest I can install
ActiveTcl and it will work.
I installed ActiveTcl from ActiveState and went back to my project. At first, I ran it like so:
$> cd ~/Source/experiments/python/tkinter
$> ./test.py
This actually worked! I could read the buttons and it behaved like it should. Then I realized I was not using pipenv, so I did a quick test:
$> pipenv run ./test.py
Now I was back to the failure state. I updated my script to display the Tcl and Tk version and sure enough when I used pipenv it was loading Tcl/Tk 8.5.9 but when I didn't use pipenv it was loading 8.6.9
So how do I fix pipenv now?
For anyone who's having the same issue and cannot switch Python version, you can easily bypass the "not showing text on buttons" problem by changing MacOs theme. System Preferences>General>Light Mode.
You should have in mind that you may encounter other problems.
After a few hours messing with it I figured it out!
The Pipfile contained a reference to Python version 3.7
Therefore pipenv install was searching my machine for any 3.7 version of Python installed. The version it found was Homebrew's, which has Tk 8.5.9 statically linked.
By updating the Pipfile to require Python 3.8 my machine started pulling my system Python, which uses the dynamically linked Tk, which I had successfully updated to 8.6.9

wxPython for Framework distribution rather than Conda

I've been struggling with getting wxPython work - I'm running a Mac, OSX 10.11.6 El Captain, so the pip install runs into /src/osx/cocoa/mediactrl.mm:52:10: fatal error: 'QTKit/QTKit.h' file not found with the new XCode, and some changes there, and won't compile. So I found an installer, that at least gets it done.
But then wx runs (I only tried to import it in fact) in my conda python 2.7.12.
My goal is to be able to play around with TensorKart and since my default python is conda, when attempting to run the repo, it tells me the usual:
This program needs access to the screen.
Please run with a Framework build of python, and only when you are
logged in on the main display of your Mac.
I found how George Reilly explains here what to do, but I cannot find the wxredirect.pth and don't know what to do with the bash script. I only have wx.pth within the conda site-packages.
So is it somehow possible to get the wxPython for my Framework 2.7.10 with the .dmg installer? After 6 hours of struggle it seems like the easiest way.
I tried:
copy conda site-packages having to do with wxPython into site-packages within a virtualenv created form the Framework Python as it was in the original G. Reilly's post which no longer works.
create alias in .bash_profile that python is the Framework version but it didn't help.
Thanks a lot!

Fixing Python 3 tkinter issues on Mac with a virtualenv

I think the short version of this question is: How do I get a virtualenv running Python 3.5 to point to the correct version of ActiveTcl on a Mac?
Here's the longer version:
I'm trying to run this Korg Electribe sample editor project on a Mac. The author has only tested it on Windows, and based on the screenshots, it appears to work. I've been able to run the basic python script fine, but as I mention in an issue that I've opened, the full window turns black after loading a file.
After doing some research, I've found that there is a known issue with Aqua Cocoa Tk, and python.org has provided some instrunctions about how to fix tkinter for Mac OS 10.9 and up. I've attempted installing both of the suggested ActiveTcl (8.5.18.0) as well as the newer 8.6.x.x version without success.
I'm pretty sure this is a different issue than Tkinter not working mac osx el capitan, since the script does run, and the window is drawn properly on launch. It's only after I've attempted to load a .all file (there's a sample file in the Github issue) that the screen goes black.
After some more research, I've found this question that seems related, but is specific to Windows: TKinter in a Virtualenv
I'm under the impression that if I can figure out what to set TCL_LIBRARY to, that I'll be able to make some head-way, but I can't seem to find that information for the packages listed on python.org.
Somewhat related, it would also seem to be helpful if I could figure out which version of Tcl/Tk that tkinter is pointing to from within Python, so if anyone could help with that as well, I'd greatly appreciate it.
Thanks!
I succeeded in using tkinter in a python3 virtualenv on OSX 10.13 by :
installing the official OSX Python 3 from https://www.python.org/
installing activeTcl from https://www.activestate.com/activetcl
creating a new virtualenv
mkvirtualenv myenv --python=python3
locating the tkinter location in the Python3 directory. For me it was here :
/usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter
creating a symbolic link in the virtualenv library pointing to the tkinter location
cd ~/.virtualenvs/myenv/lib/python3.6
ln -s /usr/local/Cellar/python3/3.6.3/Frameworks/Python.framework/Versions/3.6/lib/python3.6/tkinter tkinter

Meld has errors on OSX 10.10

I installed Meld 3.14.0 (current version as of this post) via Homebrew on OSX. Whenever I launch it, it gives me this:
Couldn't bind the translation domain. Some translations won't work.
'module' object has no attribute 'bindtextdomain'
2015-08-13 10:35:55.007 Python[2396:32534] *** WARNING: Method userSpaceScaleFactor in class
NSView is deprecated on 10.7 and later. It should not be used in new applications. Use convertRectToBacking: instead.
Now it still launches and appears to work ok. I can view the diffs of files, which is what I care about mostly. When I exit though, I get the Mac OSX dialog "Python Quit Unexpectedly" as well as this from the command line:
/usr/local/Cellar/git/2.4.6/libexec/git-core/mergetools/meld: line 1: 2396 Segmentation fault: 11 "$merge_tool_path" "$LOCAL" "$REMOTE"
EDIT I only get the segfault if I click the red X to close Meld. If I quit Python (what shows in the dock when Meld is open) via cmd+Q it closes cleanly.
The version of Meld I'm using is very recent, so I'm surprised I can't find more about this issue. My version of Python is 2.7.10.
Anyone else having this problem? I fear that when I want to actually do a merge and save I won't be able to due to the crash.
This product bug was fixed by now and version 3.14.2 succesfully installs on OS X 10.11 using brew install homebrew/gui/meld
In the future please use product issue tracker for product specific bugs. StackOverflow is not a replacement for usage of an issue tracker.
Check meld issue tracker

kivy with pycharm import error

(New in python+kivy here).
Hi, I'm trying to get python with Kivy up in running and I just wanted to know if there's a way to run Kivy apps in PyCharm since I'm getting an error:
Traceback (most recent call last):
File "C:/Kivy/kivy/examples/tutorials/pong/main.py", line 1, in <module>
import kivy
ImportError: No module named kivy
when loading this file with pycharm, notice that that's the sample game out of the box, I can run the app via right click->sendTo->kivy.bat but I don't think that large scale apps actually do it that way -.- there must be a simpler(and hopefully more graphic) way to use Kivy, after a lot of asking to Dr. Google I give up, Thanks in advance!:)
BTW: My main interest is making apps that makes basic database requests and at the same time are GUI friendly , Kivy was my first option next to WX but if there are any suggestions they are welcome :)
I just put up a tutorial on how to setup pycharm & kivy on os x
Short Version for Windows (I assume this will work):
After you install kivy, you need to create a python interpreter for kivy - if you already had python installed, it's the wrong python to do Kivy work. Check C:/Kivy/kivy/ or the contents of kivy.bat to get the path to the python.exe distributed with kivy ( I found C:\Kivy141\Python\python.exe on one page, but that may be if you install kivy manually)
When you find it, your kivy project python interpreter needt to be that one.
Good luck!
With PyCharm on OSX I had the same problem and solved it by creating a VirtualEnv in PyCharm (see PyCharm docs for this) and some Kivy paths to the virtualenv. You can find this by selecting the VirtualEnv and select the tab "Paths".
You can probably find out the correct paths by inspecting the kivy.bat file. I did something similar on the Mac.
I wanted to include a picture to show my paths settings, but my Stackoverflow karma level doesn't allow this.
PyCharm 4.0 changed the answer, now it's just set some environment variables. I updated the Kivy Wiki for setting up PyCharm on OSX
For OSX 10.10.2, kivy 1.9.0, and Pycharm 5.0.2 (free Community Edition), the instructions at the link below worked for me:
Setting up Kivy 1.9.0 with PyCharm 4.5 EAP on OS X 10.10.3
Substitute PyCharm for PyCharm-EAP in the instructions(which only occurs once).
I entered each Environment variable separately, rather than pasting them in as one long string.
Pay attention to the titles of the windows where you enter things. The instructions tell you EXACTLY which window you should be looking at.
To anyone that may see this:
Follow the wiki guide to create the symlink.
In Pycharm, add a local file for the project interpreter, then click the "more" button, go to the pencil, and manually change the link to /Applications/Kivy.app/Contents/Resources/script . That's how I got mine to work, latest PyCharm CE, Kivy, Python 3.5, and El Capitan

Categories

Resources