滚动事件后在Gtk.DrawingArea()中维护开罗图形

时间:2019-03-18 19:11:24

标签: scroll gtk pygtk cairo pygobject

我正在使用一些图像的注释工具,因此决定将GTK用于此任务。我有一个嵌套在Gtk.Viewport()中的Gtk.DrawingArea(),该嵌套在Gtk.ScrolledWindow()中,以启用绘图区域的滚动。绘制区域包含图像,并且在每次鼠标单击事件时使用Cairo在图像的顶部绘制形状。

如果我理解正确,则默认情况下滚动会导致重绘Gtk.DrawingArea(),从而使所有形状消失。有什么方法(除了保留坐标列表并在每个滚动事件上重绘每个形状外)来维护这些形状?

Sub Button1_Click()

Dim ws As Worksheet
Dim a As String
Dim b As String
Dim c As String
Dim URL As String

'Lockout Functions
   'Cancel = True

'Check for Muted Sound, Unmute

'First Question
    a = Application.InputBox("What is 1+1?")
    If a = "2" Then 'continue
    Else
    Application.Speech.Speak "Are you even trying?"
    MsgBox "Hi, you got that answer wrong"
    End If

'Second Question
    b = Application.InputBox("Finish this Sequence 1123_813__")
    If b = "1123581321" Then 'Continue
    Else
    Application.Speech.Speak "It's the Fibonacci duh!"
    MsgBox "Hi, you got that answer wrong"
    End If  

'Third Question
    c = Application.InputBox("What are the next three numbers 1, 4, 9, 16, ?")
    If c = "1,4,9,16,25,36,49" Then 'continue
    Else
    Application.Speech.Speak "Terrible!"
    MsgBox "Hi, you got that answer wrong"
    End If

'Unlock/Return Control
    'Cancel = False

End Sub

1 个答案:

答案 0 :(得分:0)

如Uli Schlachter所指出的,重绘是在每个滚动事件上执行的,因此需要跟踪添加的点(例如带有列表),并在上述代码的expose()函数中重绘每个点。