wx.grid.Grid() and versions

classic Classic list List threaded Threaded
10 messages Options
Reply | Threaded
Open this post in threaded view
|

wx.grid.Grid() and versions

Dave Kimble
This straightforward code doesn't work, leaving me wondering if my setup is correct.


#!/usr/bin/env python
import wx
import os
app
= wx.App()

# config
frame_xpos
= 0
frame_ypos
= 0
frame_width
= 640
frame_height
= 1080
frame_title
= "Network connections"
frame_icon
= "./wxpython/icon.png"
top_panel_color
= "#E0FFE0"
grid_rows
= 7
grid_columns
= 7

# frame
frame
= wx.Frame(None)
frame
.SetTitle(frame_title)
frame
.SetPosition(wx.Point(frame_xpos, frame_ypos))
frame
.SetSize(wx.Size(frame_width, frame_height))
frame
.SetIcon(wx.Icon(frame_icon))

# top panel
top_panel
= wx.Panel(frame)
top_panel
.SetBackgroundColour(top_panel_color)

# grid
grid
= wx.grid.Grid(top_panel)
grid
.CreateGrid(grid_rows, grid_columns)

# grid options

produces:
Traceback (most recent call last):
 
File "./wxpython/test2.py", line 29, in <module>
    grid
= wx.grid.Grid(top_panel)
AttributeError: 'module' object has no attribute 'Grid'

How can I tell which wxpython wrappers are being used?

What is the Python equivalent of PHP's exec(command) function, that is, where the thing being executed is a bash command?



--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.grid.Grid() and versions

Matt Newville


On Sat, Apr 27, 2019 at 9:17 PM <[hidden email]> wrote:
This straightforward code doesn't work, leaving me wondering if my setup is correct.


#!/usr/bin/env python
import wx
import os
app
= wx.App()

# config
frame_xpos
= 0
frame_ypos
= 0
frame_width
= 640
frame_height
= 1080
frame_title
= "Network connections"
frame_icon
= "./wxpython/icon.png"
top_panel_color
= "#E0FFE0"
grid_rows
= 7
grid_columns
= 7

# frame
frame
= wx.Frame(None)
frame
.SetTitle(frame_title)
frame
.SetPosition(wx.Point(frame_xpos, frame_ypos))
frame
.SetSize(wx.Size(frame_width, frame_height))
frame
.SetIcon(wx.Icon(frame_icon))

# top panel
top_panel
= wx.Panel(frame)
top_panel
.SetBackgroundColour(top_panel_color)

# grid
grid
= wx.grid.Grid(top_panel)
grid
.CreateGrid(grid_rows, grid_columns)

# grid options

produces:
Traceback (most recent call last):
 
File "./wxpython/test2.py", line 29, in <module>
    grid
= wx.grid.Grid(top_panel)
AttributeError: 'module' object has no attribute 'Grid'


You need to explicitly import `wx.grid`

    import wx
    import wx.grid

    grid = wx.grid.Grid(top_panel)

   
How can I tell which wxpython wrappers are being used?

`wx.version()` may be sufficient, or check out `wx.PlatformInfo`:

    import wx

    print(wx.version())

    print(wx.PlatformInfo)



What is the Python equivalent of PHP's exec(command) function, that is, where the thing being executed is a bash command?


Perhaps `os.execute()`  or one of the several variations of `os.spawn[lp][v][e]` is the closest; I have no clue what PHP does.   For anything complex, `subprocess.Popen` would generally be preferred.
 
--Matt 

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.grid.Grid() and versions

Matt Newville


What is the Python equivalent of PHP's exec(command) function, that is, where the thing being executed is a bash command?


Perhaps `os.execute()`  or one of the several variations of `os.spawn[lp][v][e]` is the closest; I have no clue what PHP does.   For anything complex, `subprocess.Popen` would generally be preferred.
 

Oops, that should be `os.system()`, not `os.execute()`.

--Matt

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.grid.Grid() and versions

Dave Kimble
In reply to this post by Matt Newville
Thanks, that works. Where does it say to do that in the documentation?

You need to explicitly import `wx.grid`

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.grid.Grid() and versions

Matt Newville

On Sun, Apr 28, 2019 at 5:11 PM <[hidden email]> wrote:
Thanks, that works. Where does it say to do that in the documentation?


I believe that https://wxpython.org/Phoenix/docs/html/index.html  lists the wxPython modules that are not automatically imported with `import wx`.  These are generally largish modules that you may not need for every app.  I also believe that https://wxpython.org/Phoenix/docs/html/wx.1moduleindex.html lists what *is* imported with `import wx`, with the implication that those other modules are not.   I fine the demos are an excellent companion to the API docs.

--Matt

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.grid.Grid() and versions

Dave Kimble
https://wxpython.org/Phoenix/docs/html/index.html is for Phoenix, as the URL suggests, so from there I followed the link to https://wxpython.org/Phoenix/docs/html/MigrationGuide.html but I didn't find any "import wx.grid" things there. I realise the Classic versions were "somewhat haphazard and chaotic", but it must be documented somewhere. I would expected a mention of this at the start of the definition for the wx.grid class.

On Monday, April 29, 2019 at 9:14:26 AM UTC+10, Matt Newville wrote:

On Sun, Apr 28, 2019 at 5:11 PM <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="4DWFEYxJCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dave....@...> wrote:
Thanks, that works. Where does it say to do that in the documentation?


I believe that <a href="https://wxpython.org/Phoenix/docs/html/index.html" style="font-family:Arial,Helvetica,sans-serif" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwxpython.org%2FPhoenix%2Fdocs%2Fhtml%2Findex.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGyGdy3d75geAUylzWTAFDvSdVDBQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwxpython.org%2FPhoenix%2Fdocs%2Fhtml%2Findex.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGyGdy3d75geAUylzWTAFDvSdVDBQ&#39;;return true;">https://wxpython.org/Phoenix/docs/html/index.html  lists the wxPython modules that are not automatically imported with `import wx`.  These are generally largish modules that you may not need for every app.  I also believe that <a href="https://wxpython.org/Phoenix/docs/html/wx.1moduleindex.html" style="font-family:Arial,Helvetica,sans-serif" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwxpython.org%2FPhoenix%2Fdocs%2Fhtml%2Fwx.1moduleindex.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEb1ECYQHyrsZLPL75MGrgTDFLiXA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwxpython.org%2FPhoenix%2Fdocs%2Fhtml%2Fwx.1moduleindex.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNEb1ECYQHyrsZLPL75MGrgTDFLiXA&#39;;return true;">https://wxpython.org/Phoenix/docs/html/wx.1moduleindex.html lists what *is* imported with `import wx`, with the implication that those other modules are not.   I fine the demos are an excellent companion to the API docs.

--Matt

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.grid.Grid() and versions

Matt Newville

On Sun, Apr 28, 2019 at 7:48 PM <[hidden email]> wrote:
https://wxpython.org/Phoenix/docs/html/index.html is for Phoenix, as the URL suggests,

Isn't that what you are using?  I think you did not say you were using an outdated version.  Anyway, it's the same as https://docs.wxpython.org/

so from there I followed the link to https://wxpython.org/Phoenix/docs/html/MigrationGuide.html but I didn't find any "import wx.grid" things there.

The main API documentation page says:

Modules
------------
   wx    The classes which appear in the main wx namespace.

and then gives a list of several other modules, including wx.grid (wx.adv, wx.dataview, etc).  The implication is that they are not in the main wx namespace.

I realise the Classic versions were "somewhat haphazard and chaotic", but it must be documented somewhere.

Without accepting your premise of chaos, it *is* documented somewhere.  See above. Or read https://docs.wxpython.org/wx.grid.Grid.html#wx.grid.Grid . Or read the demos.
I would expected a mention of this at the start of the definition for the wx.grid class.

Well, most places in the docs, it is described as `wx.grid.Grid`. Generally speaking, 

    >>> import foo
    >>> x = foo.bar.Biz()   # probably not going to work without `import foo.bar`

does not work unless done so deliberately.  The wxPython API doc states that they do not do this for `wx.grid`, `wx.adv`, `wx.dataview` and several other modules.

Hope that helps. I would suggest not blaming the wxPython docs too much. They are actually very good, especially given the ratio of active programmers/documentors to the number of classes and methods.   Let's be thankful for that.

--Matt

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.grid.Grid() and versions

Dave Kimble
Thanks for that.
"somewhat haphazard and chaotic" is a direct quote from the Migration Guide.

I would like to install the latest version. 
https://wiki.wxpython.org/InstallingOnUbuntuOrDebian says:
1 curl http://apt.wxwidgets.org/key.asc | sudo apt-key add -
curl: (6) Could not resolve host: apt.wxwidgets.org
So I can't get the repository, and have ended up with wxwidgets-3.0.2.0 . I don't know how.  I'm not sure how to check for the wxPython version.

What I need is a clear set of instructions for Ubuntu-18.04 (64-bit), the most popular Linux distro.
"sudo apt install wxwidgets" would be good.
I have installed Python-3, GTK3, pip, wheels, tools, six, pkconfig, Its so easy !
OK, I realise its not easy, thats why there are so many confusing explanations around.
I would suggest you accept that its not easy, or well-documented, which is the reality.

On Monday, April 29, 2019 at 12:37:11 PM UTC+10, Matt Newville wrote:

On Sun, Apr 28, 2019 at 7:48 PM <<a href="javascript:" target="_blank" gdf-obfuscated-mailto="BE7pYJxUCAAJ" rel="nofollow" onmousedown="this.href=&#39;javascript:&#39;;return true;" onclick="this.href=&#39;javascript:&#39;;return true;">dave....@...> wrote:
<a href="https://wxpython.org/Phoenix/docs/html/index.html" style="font-family:Arial,Helvetica,sans-serif" rel="nofollow" target="_blank" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwxpython.org%2FPhoenix%2Fdocs%2Fhtml%2Findex.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGyGdy3d75geAUylzWTAFDvSdVDBQ&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwxpython.org%2FPhoenix%2Fdocs%2Fhtml%2Findex.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGyGdy3d75geAUylzWTAFDvSdVDBQ&#39;;return true;">https://wxpython.org/Phoenix/docs/html/index.html is for Phoenix, as the URL suggests,

Isn't that what you are using?  I think you did not say you were using an outdated version.  Anyway, it's the same as <a href="https://docs.wxpython.org/" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fdocs.wxpython.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFrQ5-jIoeQgPyQhbPnSMpDDxMORw&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fdocs.wxpython.org%2F\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNFrQ5-jIoeQgPyQhbPnSMpDDxMORw&#39;;return true;">https://docs.wxpython.org/

so from there I followed the link to <a href="https://wxpython.org/Phoenix/docs/html/MigrationGuide.html" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwxpython.org%2FPhoenix%2Fdocs%2Fhtml%2FMigrationGuide.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHupMe2ga_ltR-Ja8giphqyurUn6A&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fwxpython.org%2FPhoenix%2Fdocs%2Fhtml%2FMigrationGuide.html\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHupMe2ga_ltR-Ja8giphqyurUn6A&#39;;return true;">https://wxpython.org/Phoenix/docs/html/MigrationGuide.html but I didn't find any "import wx.grid" things there.

The main API documentation page says:

Modules
------------
   wx    The classes which appear in the main wx namespace.

and then gives a list of several other modules, including wx.grid (wx.adv, wx.dataview, etc).  The implication is that they are not in the main wx namespace.

I realise the Classic versions were "somewhat haphazard and chaotic", but it must be documented somewhere.

Without accepting your premise of chaos, it *is* documented somewhere.  See above. Or read <a href="https://docs.wxpython.org/wx.grid.Grid.html#wx.grid.Grid" target="_blank" rel="nofollow" onmousedown="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fdocs.wxpython.org%2Fwx.grid.Grid.html%23wx.grid.Grid\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHyAZ5yypjh3hQbw2hjT8t9xH-CfA&#39;;return true;" onclick="this.href=&#39;https://www.google.com/url?q\x3dhttps%3A%2F%2Fdocs.wxpython.org%2Fwx.grid.Grid.html%23wx.grid.Grid\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNHyAZ5yypjh3hQbw2hjT8t9xH-CfA&#39;;return true;">https://docs.wxpython.org/wx.grid.Grid.html#wx.grid.Grid . Or read the demos.
I would expected a mention of this at the start of the definition for the wx.grid class.

Well, most places in the docs, it is described as `wx.grid.Grid`. Generally speaking, 

    >>> import foo
    >>> x = <a href="http://foo.bar.Biz" target="_blank" rel="nofollow" onmousedown="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ffoo.bar.Biz\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGVF4yXDtJcBfwECUsztPyH5qQ89w&#39;;return true;" onclick="this.href=&#39;http://www.google.com/url?q\x3dhttp%3A%2F%2Ffoo.bar.Biz\x26sa\x3dD\x26sntz\x3d1\x26usg\x3dAFQjCNGVF4yXDtJcBfwECUsztPyH5qQ89w&#39;;return true;">foo.bar.Biz()   # probably not going to work without `import foo.bar`

does not work unless done so deliberately.  The wxPython API doc states that they do not do this for `wx.grid`, `wx.adv`, `wx.dataview` and several other modules.

Hope that helps. I would suggest not blaming the wxPython docs too much. They are actually very good, especially given the ratio of active programmers/documentors to the number of classes and methods.   Let's be thankful for that.

--Matt

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.grid.Grid() and versions

Scott Talbert
On Mon, 29 Apr 2019, [hidden email] wrote:

> Thanks for that.
> "somewhat haphazard and chaotic" is a direct quote from the Migration Guide.
>
> I would like to install the latest version. 
> https://wiki.wxpython.org/InstallingOnUbuntuOrDebian says:
> 1 curl http://apt.wxwidgets.org/key.asc | sudo apt-key add -
> curl: (6) Could not resolve host: apt.wxwidgets.org
> So I can't get the repository, and have ended up with wxwidgets-3.0.2.0 . I
> don't know how.  I'm not sure how to check for the wxPython version.
>
> What I need is a clear set of instructions for Ubuntu-18.04 (64-bit), the
> most popular Linux distro.
> "sudo apt install wxwidgets" would be good.
> I have installed Python-3, GTK3, pip, wheels, tools, six, pkconfig, Its so
> easy !
> OK, I realise its not easy, thats why there are so many confusing
> explanations around.
> I would suggest you accept that its not easy, or well-documented, which is
> the reality.
sudo apt install python3-wxgtk4.0

will get you wxPython 4.0.1 on Ubuntu 18.04.

Scott

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: wx.grid.Grid() and versions

Matt Newville
In reply to this post by Dave Kimble

On Mon, Apr 29, 2019 at 7:03 PM <[hidden email]> wrote:
Thanks for that.
"somewhat haphazard and chaotic" is a direct quote from the Migration Guide.

Doesn't that describe the organization of the modules and namespaces in the old version of the code? 


I would like to install the latest version. 
1 curl http://apt.wxwidgets.org/key.asc | sudo apt-key add -
curl: (6) Could not resolve host: apt.wxwidgets.org
So I can't get the repository, and have ended up with wxwidgets-3.0.2.0 . I don't know how.  I'm not sure how to check for the wxPython version.


Hm, that looks like it was last edited in 2011, and describes installed wx 2.8.12 on Ubuntu 11.  Yep, that could be missing some information for installing wxPython 4 on Ubuntu 18.   If I was looking for "how to install wxpython on ubuntu", my search engine would have me led to

Checking the version of wxpython follows the very common Python convention:

>>> import wx
>>> print(wx.__version__)


What I need is a clear set of instructions for Ubuntu-18.04 (64-bit), the most popular Linux distro. 
"sudo apt install wxwidgets" would be good.

I would have tried "wxpython" (assuming that "wxwidgets" would be the C++ lib). But I do not know what Ubuntu would call "wxpython".

Or: consider wxPython as a Python package and expect that `pip install wxpython` should work.  On most linuxes this *can* work, though it installs from wxpython source and so requires a full range of developer tools and specifically developer packages for 
   libgtk3, libwebkitgtk, freeglut, libgstreamer 
and maybe other packages.   I use another Linux distro family, so those might have different names on Ubuntu, but should be readily available.  I think the link above might have more details.

Or: use a non-system Python such as Anaconda Python.  There is much to recommend this approach, including not messing with system python, not needing root privilege, and having many large and complex packages curated for you, including wxpython (`conda install wxpython`).

I have installed Python-3, GTK3, pip, wheels, tools, six, pkconfig, Its so easy !
OK, I realise its not easy, thats why there are so many confusing explanations around.
I would suggest you accept that its not easy, or well-documented, which is the reality.

Well you did sort of change the question from "how to I import wx.grid.Grid" to "how do I install wxPython on system/configuration of my choice".  ;).
The docs for how to use wxPython are very good.  But, yes, the instructions for how to install complex python pacakges on your system of choice vary wildly.  Then again, `pip install`(or `conda install`) will work most of the time, and there are not very many packages that even need detailed installation instructions.  GUI toolkits are one of the few exceptions.

--Matt

--
You received this message because you are subscribed to the Google Groups "wxPython-users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
For more options, visit https://groups.google.com/d/optout.