简体   繁体   English

Ubuntu中的wxWidgets和X11问题?

[英]wxWidgets and X11 issues in Ubuntu?

I'm trying to make a simple Dialog Based GUI using wxWidgets. 我正在尝试使用wxWidgets创建一个简单的基于对话框的GUI。 I am using X11/Xlib.h for image capturing (printscreen). 我正在使用X11 / Xlib.h进行图像捕获(打印屏幕)。 Problems start when I change anything in GUI using wxSmith (eg drag and drop new button) because it automatically changes button names to Button1,Button2... 当我使用wxSmith更改GUI中的任何内容时(例如拖放新按钮),问题就会开始,因为它会自动将按钮名称更改为Button1,Button2 ...

Button1 = new wxButton(this, ID_BUTTON1, _("About"), wxDefaultPosition, wxDefaultSize, 0, wxDefaultValidator, _T("ID_BUTTON1"));

Problem is that Button1..5 are already defined in Xh: 问题是Xh中已经定义了Button1..5:

/* button names. Used as arguments to GrabButton and as detail in ButtonPress
   and ButtonRelease events.  Not to be confused with button masks above.
   Note that 0 is already defined above as "AnyButton".  */

#define Button1         1
#define Button2         2
#define Button3         3
#define Button4         4
#define Button5         5

Can I somehow modify wxWidgets not to automatically change names or just to add my custom prefix eg somethingButton1? 我可以以某种方式修改wxWidgets使其不自动更改名称还是仅添加我的自定义前缀,例如somethingButton1吗?

Are you changing the var name in the GUI designer, or editing the cpp file directly? 您是要在GUI设计器中更改var名称,还是直接编辑cpp文件?

If you edit stuff between //(*Initialize(PanelName) and //*) in the cpp then any changes you make will be wiped out (not just the change to the button name). 如果您在cpp中//(*Initialize(PanelName)//*)之间编辑内容,则您所做的任何更改都会被清除(而不仅仅是按钮名称的更改)。

If you are looking at the Resources tab (which you should be if you're using the Drag 'n Drop), below it is the properties of the currently selected button (or other widget). 如果您正在查看“资源”选项卡(如果使用的是“拖放”,则应为该选项卡),它下面是当前所选按钮(或其他小部件)的属性。 Change the Var name property to myButton1 to change the variable name. 将“ Var name属性更改为myButton1以更改变量名。

Seems to me that you can simply write 在我看来,你可以简单地写

myButton1 = new wxButton(this, ID_BUTTON1, _("About"), ....

I see that you are using wxSmith, a Rapid Application Developer (RAD) plugin for CodeBlocks. 我看到您正在使用wxSmith,它是CodeBlocks的快速应用程序开发人员(RAD)插件。 This means that you are relying on a computer program to write your code for you, which is something that has never worked well for all the decades of effort. 这意味着您要依靠计算机程序来为您编写代码,这在几十年的努力中一直没有奏效。

My advice would be, best first: 我的建议是,最好先:

  1. Take a deep breath and write your own code. 深吸一口气,然后编写自己的代码。 You will learn a lot! 您将学到很多东西!

  2. Choose another RAD. 选择另一个RAD。 There are many available and some should be more sophisticated and adapted to running with X11. 有许多可用的功能 ,有些应该更完善,并适合与X11一起运行。

  3. Download the wxSmith code. 下载wxSmith代码。 Do a global find & replace Button1 -> wxSmith_Button1. 进行全局查找并替换Button1-> wxSmith_Button1。 Rebuild. 重建。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM