Skip to content

Commit

Permalink
Can stay still while mouse scrolling, and restore auto-scrolling mode
Browse files Browse the repository at this point in the history
once mouse scrolling to upper or lower.
  • Loading branch information
hozen committed Dec 4, 2014
1 parent 107c9b6 commit 33bb9e5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
14 changes: 12 additions & 2 deletions cali_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,18 @@ def on_ComboBoxOfUart_changed(self, widget):
self.EntryOfCommand.grab_focus()

def on_TextViewOfLog_size_allocate(self, widget, event, data=None):
if self.auto_scroll:
adj = self.ScrolledWindowOfLog.get_vadjustment()
#adj.set_value(adj.upper - adj.page_size)
gobject.idle_add(adj.set_value, (adj.upper - adj.page_size))

def on_TextViewOfLog_scroll_event(self, widget, event):
adj = self.ScrolledWindowOfLog.get_vadjustment()
#adj.set_value(adj.upper - adj.page_size)
gobject.idle_add(adj.set_value, (adj.upper - adj.page_size))
print adj.value, adj.upper-adj.page_size
if abs(adj.value-(adj.upper-adj.page_size)) < 0.1:
self.auto_scroll = True
else:
self.auto_scroll = False

def on_FileChooserButton_file_set(self, widget):
file = self.FileChooserButton.get_filename()
Expand Down Expand Up @@ -804,6 +813,7 @@ def __init__(self):
self.window = builder.get_object("window")

self.TextBufferOfLog = builder.get_object("textbuffer1")
self.auto_scroll = True
self.EntryOfCommand = builder.get_object("EntryOfCommand")
self.EntryOfSerialNumber = builder.get_object("EntryOfSerialNumber")
self.serial_number = 777
Expand Down
1 change: 1 addition & 0 deletions glades/calibration.glade
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,7 @@
<property name="cursor_visible">False</property>
<property name="buffer">textbuffer1</property>
<signal name="size-allocate" handler="on_TextViewOfLog_size_allocate" swapped="no"/>
<signal name="scroll-event" handler="on_TextViewOfLog_scroll_event" swapped="no"/>
</object>
</child>
</object>
Expand Down

0 comments on commit 33bb9e5

Please sign in to comment.