i have problem with this code:

def __init__(self,parent):
        data = [(1,2), (2,3), (3,5), (4,6), (5,8), (6,8), (10,10)]
        self.okno=wx.Frame(None,title="Graf",id=-1)
        
        sizer=wx.BoxSizer(wx.HORIZONTAL)
        ram=wx.Panel(self.okno)
        client = plot.PlotCanvas(ram)
        line = plot.PolyLine(data, legend='', colour='pink', width=1)
        gc = plot.PlotGraphics([line], 'Line Graph', 'X Axis', 'Y Axis')
        client.Draw(gc, xAxis= (0,15), yAxis= (0,15))
        sizer.Add(ram,1,0,wx.ALL)
        self.okno.SetSizer(sizer)
        self.okno.Layout()
        self.okno.Show(True)

why plot is so small? i am new in Wx...


thanks

You need to give us the full code, or we won't know where 'plot' is coming from.

import wx
import wx.lib.plot as plot
class Example:
    def __init__(self):
        data = [(1,2), (2,3), (3,5), (4,6), (5,8), (6,8), (10,10)]
        self.okno=wx.Frame(None,title="Graf",id=-1)
        
        sizer=wx.BoxSizer(wx.VERTICAL)
        ram=wx.Panel(self.okno)
        client = plot.PlotCanvas(ram)
        line = plot.PolyLine(data, legend='', colour='pink', width=1)
        gc = plot.PlotGraphics([line], 'Line Graph', 'X Axis', 'Y Axis')
        client.Draw(gc, xAxis= (0,15), yAxis= (0,15))
        sizer.Add(ram,1,0,wx.ALL)
        sizer.Add(wx.Button(self.okno,label="Button"))
        self.okno.SetSizer(sizer)
        self.okno.Layout()
        self.okno.Show(True)
okno = wx.App(0)
Example()
okno.MainLoop()

this is a little example.. In the window must be graph and several buttons, but graph is too small:(
Thanks for all post

You need to give the canvas a size, like this ... client = plot.PlotCanvas(ram, size = (300, 350))

it doesnt work.
code:

import wx,os
import wx.lib.plot as plot
class Example:
    def __init__(self):
        data = [(1,2), (2,3), (3,5), (4,6), (5,8), (6,8), (10,10)]
        self.okno=wx.Frame(None,title="Graf",id=-1)
        
        sizer=wx.BoxSizer(wx.VERTICAL)
        ram=wx.Panel(self.okno)
        client = plot.PlotCanvas(ram, size = (300, 350))
        line = plot.PolyLine(data, legend='', colour='pink', width=1)
        gc = plot.PlotGraphics([line], 'Line Graph', 'X Axis', 'Y Axis')
        client.Draw(gc, xAxis= (0,15), yAxis= (0,15))
        sizer.Add(ram,1,0,wx.ALL)
        sizer.Add(wx.Button(self.okno,label="Button"))
        self.okno.SetSizer(sizer)
        if os.path.exists("tips.txt"):
            wx.CallAfter(self.okno.ShowTip, wx.GetApp().GetTopWindow(), wx.CreateFileTipProvider("tips.txt", 0))
        self.okno.Layout()
        self.okno.Show(True)
okno = wx.App(0)
Example()
okno.MainLoop()

and i get error:

Traceback (most recent call last):
  File "C:\Documents and Settings\Blu\Plocha\aa.py", line 25, in -toplevel-
    Example()
  File "C:\Documents and Settings\Blu\Plocha\aa.py", line 12, in __init__
    client = plot.PlotCanvas(ram, size = wx.Size(300, 350))
TypeError: __init__() got an unexpected keyword argument 'size'

Solved, i rewrite class plot.PlotCanvas and now it works fine...

Glad you could solve it. Worked on my machine here XP, Python24, wx26 just fine.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.