wxPython:我的工具栏不显示Windows中的按钮

时间:2014-12-24 13:41:27

标签: python-2.7 wxpython

我做了一个小应用程序,它在linux中运行良好。但是,我在Windows 7中的工具栏遇到了一些问题。 工具栏上有一些Windows没有显示的按钮(但是,在Linux中有)。我使用的是Python 2.7和wxPython 2.8。

我不知道我错过了什么。

此致 克里斯蒂安。

import wx
from wx.lib.pubsub import Publisher
from excel import excelmaker
from model import Model
from ObjectListView import ColumnDefn, ObjectListView
import utils
import threading

wildcard = "Excel (*.xlsx)|*.xlsx|" \
        "All files (*.*)|*.*"

class ApplicationGui(wx.App):

    def __init__(self, redirect=False, filename=None):
        wx.App.__init__(self, redirect, filename)

    def OnInit(self):
        # create frame here
        frame = MainFrame()
        frame.Show()
        return True

class MainPanel(wx.Panel):
    def __init__(self,parent):
        self.exportText=''

        wx.Panel.__init__(self,parent=parent, id=wx.ID_ANY)

        self.objectListView = ObjectListView(self, wx.ID_ANY,style=wx.LC_REPORT|wx.SUNKEN_BORDER)
        self.objectListView.cellEditMode = ObjectListView.CELLEDIT_SINGLECLICK
        self.objectListView.SetObjects([Model()])

        mainSizer = wx.BoxSizer(wx.VERTICAL)
        self.create_toolbar(mainSizer)
        mainSizer.Add(self.progress, 0, wx.EXPAND)
        mainSizer.Add(self.objectListView, 1, wx.ALL|wx.EXPAND, 5)
        self.SetSizer(mainSizer)

    def create_toolbar(self,sizer):
        toolbar = wx.ToolBar(self)

        loadBtn = toolbar.AddLabelTool(wx.ID_ANY, 'Cargar Excel', wx.Bitmap('resources/open.png'), shortHelp='Cargar Excel')
        pasteBtn = toolbar.AddLabelTool(wx.ID_ANY, 'Pegar', wx.Bitmap('resources/paste.png'), shortHelp='Pegar Columnas')
        cleanBtn = toolbar.AddLabelTool(wx.ID_ANY, 'Borrar', wx.Bitmap('resources/clean.png'), shortHelp='Borrar tabla')
        toolbar.AddSeparator()
        addBtn = toolbar.AddLabelTool(wx.ID_ANY, 'Agregar', wx.Bitmap('resources/add.png'), shortHelp='Agregar fila')

        toolbar.AddSeparator()
        self.exportText = wx.TextCtrl(toolbar, -1, size=(140,-1))
        self.exportText.SetValue('output.xlsx')
        toolbar.AddControl(self.exportText)
        exportBtn = toolbar.AddLabelTool(wx.ID_ANY, 'Exportar', wx.Bitmap('resources/export.png'), shortHelp='Generar Excel')

        toolbar.AddSeparator()
        about = toolbar.AddLabelTool(wx.ID_ANY, 'Acerca', wx.Bitmap('resources/about.png'), shortHelp='Ayuda')


        randomId = wx.NewId()
        self.Bind(wx.EVT_MENU, self.onPaste, id=randomId)
        accel_tbl = wx.AcceleratorTable([(wx.ACCEL_CTRL,  ord('V'), randomId )])
        self.SetAcceleratorTable(accel_tbl)

        sizer.Add(toolbar, 0, wx.EXPAND)
        self.Bind(wx.EVT_TOOL, self.onOpenFile, loadBtn)
        self.Bind(wx.EVT_TOOL, self.onPaste, pasteBtn)
        self.Bind(wx.EVT_TOOL, self.onClean, cleanBtn)
        self.Bind(wx.EVT_TOOL, self.onExport, exportBtn)
        self.Bind(wx.EVT_TOOL, self.onAddRow, addBtn)
        self.Bind(wx.EVT_TOOL, self.onAbout, about)

class MainFrame(wx.Frame):
    def __init__(self):
        wx.Frame.__init__(self, parent=None, id=wx.ID_ANY,
                      title="Exceltronic", size=(800,600))
        panel = MainPanel(self)

1 个答案:

答案 0 :(得分:2)