- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在寻找一种可以将 wxPython GUI 元素添加到 pygame 中的方法。如果有替代方法可以解决将 GUI 元素添加到 pygame 的目的,请提出建议。我在安装 PGU 时遇到问题。感谢您的帮助。
最佳答案
不;您可以将 wxWidgets 添加到 PyGame。添加打开/保存对话框、按钮等是微不足道的。有时当您尝试共享区域时会变得令人讨厌(如上所述,存在冲突的窗口系统),但这绝对是可行的。
我是几年前写的,所以很乱;但至少它很简单。它应该可以帮助您入门:
class SDLThread:
def __init__(self,screen):
self.m_bKeepGoing = self.m_bRunning = False
self.screen = screen
self.color = (255,0,0)
self.rect = (10,10,100,100)
def Start(self):
self.m_bKeepGoing = self.m_bRunning = True
thread.start_new_thread(self.Run, ())
def Stop(self):
self.m_bKeepGoing = False
def IsRunning(self):
return self.m_bRunning
def Run(self):
while self.m_bKeepGoing:
pass
## GetInput()
## Draw()
self.m_bRunning = False;
class SDLPanel(wx.Panel):
def __init__(self,parent,ID,tplSize):
global pygame
wx.Panel.__init__(self, parent, ID, size=tplSize)
self.Fit()
os.environ['SDL_WINDOWID'] = str(self.GetHandle())
os.environ['SDL_VIDEODRIVER'] = 'windib'
import pygame
pygame.init()
icon = pygame.Surface((1,1));icon.set_alpha(0);pygame.display.set_icon(icon)
global Surface
Surface = pygame.display.set_mode(tplSize)
self.thread = SDLThread(Surface)
self.thread.Start()
def __del__(self):
self.thread.Stop()
关于user-interface - 在 pygame 中添加 wxpython,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/8798043/
您好,我想知道是否有办法检查是否按住了某个键。 这是一个情况示例 self.button2.Bind(wx.EVT_LEFT_DOWN, self.clickedbutton) def clicked
我正在使用 wxPython 设计一个表单。请注意图片中的搜索面板:“搜索依据:”标签、嵌套在它上面的组合框和搜索控件——它们的文本都与顶部对齐。如何将它们全部对齐(垂直)在中间? 这是搜索面板代码:
我对以下代码有一个我不明白的问题。 为什么是panel1不扩大? 谢谢。 import wx class MyFrame(wx.Frame): def __init__(self, paren
我刚刚开始使用 wxPython。我有以下代码: import wx class SASFrame(wx.Frame): def __init__(self,parent,id,title):
是否可以以列表的形式获取wx.ListCtrl列中的所有值(项目)? 我在文档中看到您可以获取指定的项目,但不能获取整个列,GetValue() 也不起作用,有什么帮助吗? 最佳答案 这是一种方法:
我需要通过单击按钮在 wxpython 中创建一个额外的新窗口(与主窗口在物理上是分开的)。我想在不关闭最后一个窗口的情况下执行此操作。 这是我到目前为止所拥有的: class Prototype(w
我正在创建一个文件对话框,允许用户在我的应用程序中编辑文件后保存文件。我想在对话框中添加一个复选框,以便用户可以选择保存文件的格式。我想我需要创建一些继承自 FileDialog 的新类,并将一个复选
我正在创建一个文件对话框,允许用户在我的应用程序中编辑文件后保存文件。我想在对话框中添加一个复选框,以便用户可以选择保存文件的格式。我想我需要创建一些继承自 FileDialog 的新类,并将一个复选
我已经编写了我的第一个 wxpython 应用程序并且它运行良好,但是我在正确调整主窗口的大小方面遇到了困难。该面板包含一个 wx.BoxSizer,后者又包含一个 wx.FlexGridSizer,
在 wxpython 中使用 SetTransparent(val) 可以使整个框架透明。但是我可以让其中的单个面板透明吗? 我试过使用 panelobj.SetTransparent(val) 但没
我读了这个Style Guide for wxPython code其中说: 3. Don't use IDs. There is very rarely a good reason to use t
我的顶级窗口需要知道自定义控件的内部状态何时发生变化,以便它可以更新 GUI 的各个其他部分。如何在控件中生成自定义事件,以便它可以传播并由顶级窗口处理? 最佳答案 我知道这是一个老问题,但是在 wx
如果这是正确的词,我正在寻找一种方法来获取小部件,例如面板设备上下文。我想获取面板的位图及其所有子小部件,以便我可以在油漆 DC 中操纵它以淡入淡出面板的动画。这是可能的,如果是这样,代码是什么?我希
我在我的 RHEL6 系统上安装了 Anaconda Python。为了运行 gnuradio,我需要 wxPython。出于这个原因,我做到了 conda install wxpython 问题是当
我想要一个只接受数字的文本控件。 (只是整数值,例如 45 或 366) 最好的方法是什么? 最佳答案 我必须做类似的事情,检查字母数字代码。 EVT_CHAR 上的提示是正确的: class Tes
用于 wxPython 的最佳拖放式 GUI 生成器?我试过 wxGlade 但它不是拖放,发现它很难理解,你必须使用 sizer。我更喜欢像 VisualTinker 那样完全拖放的应用程序,但对于
问题:我在 Ubuntu 12.04 上安装 wxPython 时遇到问题。我想找到一种简单直接的方法来做到这一点。 到目前为止我做了什么:到目前为止我能找到的最相关的说明可以在这里找到:http:/
我正在尝试在 wxPython 2.8(使用 Python 2.7)中编写一个 GUI,其中涉及在 sizer 中布置几个 wx.StaticText。我想要的是一个 sizer,如果它检测到当前行的
我有一个只有一个 child 的 wx.Frame。在设置 child 的 wx.Sizer 时,我可以使用 wx.SHAPED 标志,它保持 child 的宽高比锁定。但是,Frame 在纵横比方面
我已经尝试了很多次来找到这个路径但无济于事(链接:How do I import modules in pycharm?)我认为这是因为我使用的是较新版本的 PyCharm,但这是我的项目解释器: 我
我是一名优秀的程序员,十分优秀!