下面,我在一个框架内有一个面板.为什么我无法抽到面板?我只是得到一个纯白色的屏幕.如果我摆脱面板并直接绘制到框架......它的工作原理.任何帮助,将不胜感激.
import wx
class MyFrame(wx.Frame):
def __init__(self):
wx.Frame.__init__(self,None,-1,'window',(200,200),(600,600))
self.Center()
self.panel=wx.Panel(self)
self.panel.SetBackgroundColour('white')
self.firstpoint=wx.Point(300,300)
self.secondpoint=wx.Point(400,400)
self.Bind(wx.EVT_PAINT,self.onPaint)
def onPaint(self,event):
dc=wx.PaintDC(self.panel)
dc.DrawLine(self.firstpoint.x,self.firstpoint.y,
self.secondpoint.x,self.secondpoint.y)
Run Code Online (Sandbox Code Playgroud) 我试图获得一个简单的表面视图来响应触摸事件.下面的应用程序启动但不响应触摸事件.我有一个Log.i语句来确认(通过打印到控制台)触摸事件是否正常工作.谁能告诉我我做错了什么?
这是我的主要活动
public class MainActivity extends Activity {
public static int screenWidth, screenHeight;
public static boolean running=true;
public static MainSurface mySurface;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
//this gets the size of the screen
DisplayMetrics displaymetrics = new DisplayMetrics();
getWindowManager().getDefaultDisplay().getMetrics(displaymetrics);
screenWidth = displaymetrics.widthPixels;
screenHeight = displaymetrics.heightPixels;
Log.i("MainActivity", Integer.toString(screenWidth) + " " + Integer.toString(screenHeight));
mySurface = new MainSurface(this);
setContentView(mySurface);
}
}
Run Code Online (Sandbox Code Playgroud)
这是表面视图类
public class MainSurface extends SurfaceView implements OnTouchListener {
public MainSurface(Context context) {
super(context);
}
@Override
public boolean onTouch(View …
Run Code Online (Sandbox Code Playgroud)