我的 Windows 8 上安装了带有 wxWidgets 2.8.11.0 的 python 2.7。如果我执行以下代码:
import wx
app = wx.App( redirect = False )
wnd = wx.Frame( parent = None )
widget = wx.ListCtrl( parent = wnd, style = wx.LC_REPORT )
widget.InsertColumn( 0, "items" )
widget.InsertStringItem( 0, "foo" )
widget.InsertStringItem( 1, "bar" )
widget.InsertStringItem( 2, "baz" )
widget.Select( 1 )
wnd.Show()
app.MainLoop()
Run Code Online (Sandbox Code Playgroud)
我看到了一个包含 3 个项目列表的窗口,第二个被选中。但是如果我按“向下”键 -选择了第一项!是否可以选择项目,因此按“向上”和“向下”键将移动现有选择并且不会跳到第一个项目?
我正在与我的 wxTextCtrl 解决一个烦人的问题。无论我尝试什么,都无法添加新行。wxTextCtrl 显示一个方形字符而不是一个新行。
这是相关的代码:
wxTextCtrl * detail = new wxTextCtrl (this,wxID_ANY);
detail->SetWindowStyle(wxTE_MULTILINE);
detail->SetEditable(false);
detail->AppendText("Some text");
detail->AppendText("\n New line");
detail->AppendText("\n An other new line\n");
detail->AppendText("Again a new line");
Run Code Online (Sandbox Code Playgroud)
我得到:
一些文字◻◻换行◻◻换行◻◻换行◻◻再换行
首先我认为Multiline属性有问题但detail->IsMultiLine()返回true
任何帮助将不胜感激,
我正在尝试使用计时器和函数的输出来更新一些静态文本。
代码在这里:代码。
我对 wxPython 知之甚少,这是我不明白的许多事情之一,这令人抓狂,如果我打印 apper 的输出来控制台它可以完美运行,我想要做的就是将打印出来的内容打印到控制台应用于文本。
我究竟做错了什么?
我有一个现有的 wxWidgets 项目,我试图在 Visual Studio 2010 下编译它(该项目可能是用旧版本的 Visual Studio 创建的 - 甚至可能是 VS2003)。我编译了 wxWidgets 库(也包括我的项目中的路径)。现在编译我的项目时,出现此错误:
1>------ Build started: Project: Terminals, Configuration: Debug Win32 ------
1>Build started 8/24/2015 10:56:23 AM.
1>InitializeBuildStatus:
1> Touching "Debug\Terminals.unsuccessfulbuild".
1>ClCompile:
1> All outputs are up-to-date.
1>ResourceCompile:
1> All outputs are up-to-date.
1>ManifestResourceCompile:
1> All outputs are up-to-date.
1>Link:
1> All outputs are up-to-date.
1>Manifest:
1>
1>wx\msw\wx.manifest : general error c1010070: Failed to load and parse the manifest. The system cannot find the path specified.
1>
1> …Run Code Online (Sandbox Code Playgroud) 我的规格是最新的(OS X El Capitan,10.11)。以下是我迄今为止尝试过的详细信息。
我遵循了 wxWidgets 下载中包含的(终端)安装步骤:
mkdir build-cocoa-debug
cd build-cocoa-debug
../configure --enable-debug
make
cd samples; make;cd ..
cd demos; make;cd ..
Run Code Online (Sandbox Code Playgroud)
然后,我按照wxWidgets wiki 指南创建 Xcode 项目。
当然,有很多编译错误。在处理了错误类型的包含之后,仍然存在问题。在大多数情况下,它们是未声明的标识符和不完整的类型,但我的注意力特别集中在一个:
"No Target! You should use wx-config program for compilation flags!"
Run Code Online (Sandbox Code Playgroud)
经过研究,我相信我需要使用 wx-config 来查找要输入到 Xcode 中的“Other Linker Flags”选项中的标志。但是,我似乎无法在终端中使用 wx-config。
我不确定我是否在处理核心问题。如果是,我该如何使用 wx-config?如果我不是,请引导我朝着正确的方向前进。
谢谢你。
我已经使用 wx-config 来查找我需要将哪些标志输入到 Xcode 中的“其他链接器标志”和“预处理器宏”中。这大大减少了我面临的错误和警告的数量。
不幸的是,这些新错误对我来说很深奥:
如何消除这些错误以便我可以运行这个项目?
所以,我在VS2017有一个项目,VS2017最近收到了更新。然后,我将所有 wxWidgets 模块作为项目添加到我的初始解决方案中,并处理了构建顺序,因此它们以正确的顺序构建。
但是,我总是收到此错误:
C:\Programs\Visual Studio 2017\Common7\IDE\VC\VCTargets\Microsoft.Cpp.Common.props(144,5): warning
MSB4211: The property "WindowsTargetPlatformVersion" is being set to a value for the first time, but it was already consumed at
"C:\Programs\Visual Studio 2017\Common7\IDE\VC\VCTargets\Microsoft.Cpp.WindowsSDK.props (29,5)".
Run Code Online (Sandbox Code Playgroud)
但它没有告诉我如何修复它。据我所知,单个项目的属性没有按照应评估的顺序进行评估。
如何定义属性表排序?我到底需要改变什么?
也不是我不能更改项目文件或任何连接到 wxWidgets 的东西,因为它是我存储库中的一个子模块,并且所做的任何更改都无法保存到存储库中。
wxPython从cmd2解释器命令创建非阻塞GUI 窗口wx.App?我正在使用该cmd2模块在 Python 3.x 中创建命令行解释器。我的解释器中的一个命令将允许我创建一个“非阻塞” wxPythonGUI 窗口,该窗口带有一个在单独线程中运行的倒数计时器。它需要与主解释器线程分开运行,否则它将阻止在计时器运行时输入其他命令。
当我尝试使用该wxTimer对象来允许我的 GUI 更新其进度条并检查剩余时间时,我收到以下错误:
wx._core.wxAssertionError: C++ assertion "wxThread::IsMain()" failed at ..\..\src\common\timerimpl.cpp(60) in wxTimerImpl::Start(): timer can only be started from the main thread
Run Code Online (Sandbox Code Playgroud)
任何启动计时器的尝试都会破坏代码。例如,下面的简单代码不起作用:
import wx
import threading
import cmd2
class TimerFrame(wx.Frame):
def __init__(self, time):
super().__init__(None, title=str(time), size=(300, 300))
self.InitUI()
def InitUI(self):
self.timer = wx.Timer(self, 1)
self.timer.Start(100)
self.Bind(wx.EVT_TIMER, self.OnTimer, id=1)
self.Show()
def OnTimer(self, event):
print("Updating")
class Interpreter(cmd2.Cmd):
def __init__(self):
super().__init__()
self.app = wx.App() …Run Code Online (Sandbox Code Playgroud) 这是我的代码:
class TabTwo(wx.Panel):
def __init__(self, parent):
wx.Panel.__init__(self, parent)
self.resetButton = wx.Button(self, label="Reset")
self.contactButton = wx.Button(self, label="Contact")
self.copyrightButton = wx.Button(self, label="Copyright")
v_sizer = wx.BoxSizer(wx.VERTICAL)
h_sizer = wx.BoxSizer(wx.HORIZONTAL)
v_sizer.Add(self.resetButton, 0, wx.EXPAND, 30)
v_sizer.Add(self.contactButton, 0, wx.EXPAND, 30)
v_sizer.Add(self.copyrightButton, 0, wx.EXPAND, 30)
self.SetSizer(v_sizer)
Run Code Online (Sandbox Code Playgroud)
我正在尝试使用 wxWidgets 和 wxFormBuilber 制作一个基本的 GUI,以显示国际象棋游戏板和精灵表中的棋子。我真的很感激一些示例代码:
wxwidgets ×10
c++ ×4
python ×4
wxpython ×4
python-3.x ×2
image ×1
macos ×1
wxtextctrl ×1
xcode ×1
xcode7 ×1