示例#1
0
def gtkTextviewCompare(widgetpath, targettext, tolerance=None):
    widget = gtklogger.findWidget(widgetpath)
    msgbuffer = gtklogger.findWidget(widgetpath).get_buffer()
    text = msgbuffer.get_text(msgbuffer.get_start_iter(),
                              msgbuffer.get_end_iter())
    if not fp_string_compare(text, targettext, tolerance):
        print >> sys.stderr, ("Textview compare failed for %s, >%s<!=>%s<."
                              % (widgetpath, text, targettext))
        return False
    return True
示例#2
0
文件: generics.py 项目: song2001/OOF2
def gtkTextviewCompare(widgetpath, targettext, tolerance=None):
    widget = gtklogger.findWidget(widgetpath)
    msgbuffer = gtklogger.findWidget(widgetpath).get_buffer()
    text = msgbuffer.get_text(msgbuffer.get_start_iter(),
                              msgbuffer.get_end_iter())
    if not fp_string_compare(text, targettext, tolerance):
        print >> sys.stderr, ("Textview compare failed for %s, >%s<!=>%s<." %
                              (widgetpath, text, targettext))
        return False
    return True
示例#3
0
文件: generics.py 项目: song2001/OOF2
def skeletonSelectionTBSizeCheck(windowname, category, n):
    # Check that the right size is displayed in the Skeleton Selection
    # toolbox. 'category' must be "Element", "Node", or "Segment".
    text = gtklogger.findWidget(
        '%s:Pane0:Pane1:Pane2:TBScroll:Skeleton Selection:%s:size' %
        (windowname, category))
    return eval(text.get_text()) == n
示例#4
0
def skeletonSelectionTBSizeCheck(windowname, category, n):
    # Check that the right size is displayed in the Skeleton Selection
    # toolbox. 'category' must be "Element", "Node", or "Segment".
    text = gtklogger.findWidget(
        '%s:Pane0:Pane1:Pane2:TBScroll:Skeleton Selection:%s:size' %
        (windowname, category))
    return eval(text.get_text()) == n
示例#5
0
文件: generics.py 项目: song2001/OOF2
def menuSensitive(menu, item):
    topmenuwidget = gtklogger.findWidget(menu)
    if not topmenuwidget:
        print >> sys.stderr, "Didn't find widget for", menu
    menuitemwidget = gtklogger.findMenu(topmenuwidget, item)
    if not menuitemwidget:
        print >> sys.stderr, "Didn't find widget for %s:%s" % (menu, item)
    return _widget_sensitive(menuitemwidget)
示例#6
0
def menuSensitive(menu, item):
    topmenuwidget = gtklogger.findWidget(menu)
    if not topmenuwidget:
        print >> sys.stderr, "Didn't find widget for", menu
    menuitemwidget = gtklogger.findMenu(topmenuwidget, item)
    if not menuitemwidget:
        print >> sys.stderr, "Didn't find widget for %s:%s" % (menu, item)
    return _widget_sensitive(menuitemwidget)
示例#7
0
def treeViewSelectCheck(widgetpath, col):
    # Returns the contents of the given column of a TreeStore in the
    # selected row of the given TreeView.
    treeview = gtklogger.findWidget(widgetpath)
    selection = treeview.get_selection()
    model, iter = selection.get_selected()
    if iter is not None:
        return model[iter][col]
示例#8
0
文件: generics.py 项目: song2001/OOF2
def treeViewSelectCheck(widgetpath, col):
    # Returns the contents of the given column of a TreeStore in the
    # selected row of the given TreeView.
    treeview = gtklogger.findWidget(widgetpath)
    selection = treeview.get_selection()
    model, iter = selection.get_selected()
    if iter is not None:
        return model[iter][col]
示例#9
0
文件: generics.py 项目: song2001/OOF2
def listViewSelectedRowNo(widgetpath):
    # widgetpath must be a TreeView displaying a ListStore.  Returns
    # the index of the selected row, or None if nothing is selected.
    treeview = gtklogger.findWidget(widgetpath)
    selection = treeview.get_selection()
    model, iter = selection.get_selected()
    if iter is not None:
        return model.get_path(iter)[0]
    return None  # nothing selected
示例#10
0
def chooserStateCheck(widgetpath, choice):
    # only for ChooserWidget, not ChooserListWidget.  Checks that the
    # currently selected item is 'choice'.
    combobox = gtklogger.findWidget(widgetpath)
    index = combobox.get_active()
    if index == -1:
        return choice is None
    model = combobox.get_model()
    return choice == model[index][0]
示例#11
0
def listViewSelectedRowNo(widgetpath):
    # widgetpath must be a TreeView displaying a ListStore.  Returns
    # the index of the selected row, or None if nothing is selected.
    treeview = gtklogger.findWidget(widgetpath)
    selection = treeview.get_selection()
    model, iter = selection.get_selected()
    if iter is not None:
        return model.get_path(iter)[0]
    return None                         # nothing selected
示例#12
0
文件: generics.py 项目: song2001/OOF2
def chooserStateCheck(widgetpath, choice):
    # only for ChooserWidget, not ChooserListWidget.  Checks that the
    # currently selected item is 'choice'.
    combobox = gtklogger.findWidget(widgetpath)
    index = combobox.get_active()
    if index == -1:
        return choice is None
    model = combobox.get_model()
    return choice == model[index][0]
示例#13
0
文件: generics.py 项目: song2001/OOF2
def gtkTextviewHead(widgetpath, targettext):
    msgbuffer = gtklogger.findWidget(widgetpath).get_buffer()
    text = msgbuffer.get_text(msgbuffer.get_start_iter(),
                              msgbuffer.get_end_iter())
    ok = text.startswith(targettext)
    if not ok:
        print >> sys.stderr, \
          ("gtkTextviewHead failed for %s: text =>%s< doesn't start with >%s<"
           % (widgetpath, text, targettext))
    return ok
示例#14
0
def gtkTextviewHead(widgetpath, targettext):
    msgbuffer = gtklogger.findWidget(widgetpath).get_buffer()
    text = msgbuffer.get_text(msgbuffer.get_start_iter(),
                              msgbuffer.get_end_iter())
    ok = text.startswith(targettext)
    if not ok:
        print >> sys.stderr, \
          ("gtkTextviewHead failed for %s: text =>%s< doesn't start with >%s<"
           % (widgetpath, text, targettext))
    return ok
示例#15
0
def gtkTextviewTail(widgetpath, targettext, tolerance=None):
    msgbuffer = gtklogger.findWidget(widgetpath).get_buffer()
    text = msgbuffer.get_text(msgbuffer.get_start_iter(),
                              msgbuffer.get_end_iter())
    if not fp_string_compare_tail(text, targettext, tolerance):
        print >> sys.stderr, (("gtkTextviewTail failed for %s\n"
                               "expected =>%s<=\ngot =>%s<=")
                              % (widgetpath, targettext, text))
        return False
    return True
示例#16
0
文件: generics.py 项目: song2001/OOF2
def gtkTextviewTail(widgetpath, targettext, tolerance=None):
    msgbuffer = gtklogger.findWidget(widgetpath).get_buffer()
    text = msgbuffer.get_text(msgbuffer.get_start_iter(),
                              msgbuffer.get_end_iter())
    if not fp_string_compare_tail(text, targettext, tolerance):
        print >> sys.stderr, (("gtkTextviewTail failed for %s\n"
                               "expected =>%s<=\ngot =>%s<=") %
                              (widgetpath, targettext, text))
        return False
    return True
示例#17
0
文件: generics.py 项目: song2001/OOF2
def gtkTextCompare(widgetpath, targettext, tolerance=None):
    gtktxt = gtklogger.findWidget(widgetpath)
    if not gtktxt:
        print >> sys.stderr, "Text widget not found: %s." % widgetpath
        return False
    sourcetext = string.strip(gtktxt.get_text())
    if not fp_string_compare(sourcetext, targettext, tolerance):
        print >> sys.stderr, ("Text compare failed for path %s, >%s< != >%s<" %
                              (widgetpath, sourcetext, targettext))
        return False
    return True
示例#18
0
文件: tests.py 项目: anilkunwar/OOF2
def selectedPropertyCheck(propertypath):
    # Check that the given Property is selected in the Property Pane.
    from ooflib.engine.IO.GUI import materialsPage
    propertyTree = materialsPage.materialspage.propertypane.propertytree
    prop = propertyTree.tree[propertypath]

    treeview = gtklogger.findWidget(
        'OOF2:Materials Page:Pane:Property:PropertyScroll:PropertyTree')
    selection = treeview.get_selection()
    model, iter = selection.get_selected()
    return model[iter][1] is prop
示例#19
0
文件: tests.py 项目: song2001/OOF2
def selectedPropertyCheck(propertypath):
    # Check that the given Property is selected in the Property Pane.
    from ooflib.engine.IO.GUI import materialsPage
    propertyTree = materialsPage.materialspage.propertypane.propertytree
    prop = propertyTree.tree[propertypath]

    treeview = gtklogger.findWidget(
        'OOF2:Materials Page:Pane:Property:PropertyScroll:PropertyTree')
    selection = treeview.get_selection()
    model, iter = selection.get_selected()
    return model[iter][1] is prop
示例#20
0
def gtkTextCompare(widgetpath, targettext, tolerance=None):
    gtktxt = gtklogger.findWidget(widgetpath)
    if not gtktxt:
        print >> sys.stderr, "Text widget not found: %s." % widgetpath
        return False
    sourcetext = string.strip(gtktxt.get_text())
    if not fp_string_compare(sourcetext, targettext, tolerance):
        print >> sys.stderr, ("Text compare failed for path %s, >%s< != >%s<"
                              % (widgetpath, sourcetext, targettext))
        return False
    return True
示例#21
0
def gtkFloatCompare(widgetpath, targetval, tolerance=1.e-6):
    gtktxt = gtklogger.findWidget(widgetpath)
    if not gtktxt:
        print >> sys.stderr, "Text widget not found: %s." % widgetpath
        return False
    sourceval = float(gtktxt.get_text())
    if abs(sourceval - targetval) > tolerance:
        print >> sys.stderr, ("Floating point comparison failed for %s, %g!=%g"
                              % (widgetpath, sourceval, targetval))
        return False
    return True
示例#22
0
文件: generics.py 项目: song2001/OOF2
def gtkFloatCompare(widgetpath, targetval, tolerance=1.e-6):
    gtktxt = gtklogger.findWidget(widgetpath)
    if not gtktxt:
        print >> sys.stderr, "Text widget not found: %s." % widgetpath
        return False
    sourceval = float(gtktxt.get_text())
    if abs(sourceval - targetval) > tolerance:
        print >> sys.stderr, (
            "Floating point comparison failed for %s, %g!=%g" %
            (widgetpath, sourceval, targetval))
        return False
    return True
示例#23
0
def chooserListStateCheckN(widgetpath, choices):
    # Just like chooserListStateCheck, but choices is a list of integers
    treeview = gtklogger.findWidget(widgetpath)
    selection = treeview.get_selection()
    model, paths = selection.get_selected_rows()
    if len(paths) != len(choices):
        print >> sys.stderr, "Wrong number of selections:", len(paths), "!=", len(choices)
        return False
    selected = [p[0] for p in paths]
    if selected == choices:
        return True
    print >> sys.stderr, "Selected rows are", selected
    return False
示例#24
0
def pixelSelectionTBSizeCheck(windowname, minpxls, maxpxls=None):
    # Check that the pixel selection size is displayed correctly in
    # the graphics window.  Since different versions of ImageMagick
    # can cause pixel selection operations to work differently after
    # image modifications, it's possible to specify a range of pixel
    # counts for this test.
    text = gtklogger.findWidget(
        '%s:Pane0:Pane1:Pane2:TBScroll:Pixel Selection:size' % windowname)
    n = eval(text.get_text())
    if maxpxls is None:
        return n == minpxls
    else:
        return minpxls <= n <= maxpxls
示例#25
0
文件: generics.py 项目: song2001/OOF2
def pixelSelectionTBSizeCheck(windowname, minpxls, maxpxls=None):
    # Check that the pixel selection size is displayed correctly in
    # the graphics window.  Since different versions of ImageMagick
    # can cause pixel selection operations to work differently after
    # image modifications, it's possible to specify a range of pixel
    # counts for this test.
    text = gtklogger.findWidget(
        '%s:Pane0:Pane1:Pane2:TBScroll:Pixel Selection:size' % windowname)
    n = eval(text.get_text())
    if maxpxls is None:
        return n == minpxls
    else:
        return minpxls <= n <= maxpxls
示例#26
0
文件: generics.py 项目: song2001/OOF2
def chooserListStateCheckN(widgetpath, choices):
    # Just like chooserListStateCheck, but choices is a list of integers
    treeview = gtklogger.findWidget(widgetpath)
    selection = treeview.get_selection()
    model, paths = selection.get_selected_rows()
    if len(paths) != len(choices):
        print >> sys.stderr, "Wrong number of selections:", len(
            paths), "!=", len(choices)
        return False
    selected = [p[0] for p in paths]
    if selected == choices:
        return True
    print >> sys.stderr, "Selected rows are", selected
    return False
示例#27
0
文件: tests.py 项目: anilkunwar/OOF2
def selectedMatlPropertyCheck(propertypath):
    # Check that the given Property is selected in the list of
    # Properties in the Material Pane.  propertypath should be None if
    # no Property is selected.
    matproplist = gtklogger.findWidget(
        'OOF2:Materials Page:Pane:Material:PropertyListScroll:PropertyList')
    selection = matproplist.get_selection()
    model, iter = selection.get_selected()
    if not iter and propertypath is None:
        return True
    if model[iter][0] == propertypath:
        return True
    print "Selected property is %s. Expected %s." \
          % (model[iter][0], propertypath)
    return False
示例#28
0
文件: tests.py 项目: song2001/OOF2
def selectedMatlPropertyCheck(propertypath):
    # Check that the given Property is selected in the list of
    # Properties in the Material Pane.  propertypath should be None if
    # no Property is selected.
    matproplist = gtklogger.findWidget(
        'OOF2:Materials Page:Pane:Material:PropertyListScroll:PropertyList')
    selection = matproplist.get_selection()
    model, iter = selection.get_selected()
    if not iter and propertypath is None:
        return True
    if model[iter][0] == propertypath:
        return True
    print "Selected property is %s. Expected %s." \
          % (model[iter][0], propertypath)
    return False
示例#29
0
def treeViewColCheck(widgetpath, col, choices, tolerance=None):
    # Check that the contents of the given column of a TreeView match
    # the given list of choices.  'widgetpath' is the gtklogger path
    # to the gtk TreeView.  'col' is actually a TreeStore or ListStore
    # column number.
    treeview = gtklogger.findWidget(widgetpath)
    liststore = treeview.get_model()
    if len(liststore) != len(choices):
        print >> sys.stderr, "length mismatch: %d!=%d" % (len(liststore),
                                                          len(choices))
        return False
    for i,x in enumerate(liststore):
        if choices[i] != None:
            if not fp_string_compare(x[col], choices[i], tolerance):
                print >> sys.stderr, x[col], '!=', choices[i]
                return False
    return True
示例#30
0
文件: generics.py 项目: song2001/OOF2
def treeViewColCheck(widgetpath, col, choices, tolerance=None):
    # Check that the contents of the given column of a TreeView match
    # the given list of choices.  'widgetpath' is the gtklogger path
    # to the gtk TreeView.  'col' is actually a TreeStore or ListStore
    # column number.
    treeview = gtklogger.findWidget(widgetpath)
    liststore = treeview.get_model()
    if len(liststore) != len(choices):
        print >> sys.stderr, "length mismatch: %d!=%d" % (len(liststore),
                                                          len(choices))
        return False
    for i, x in enumerate(liststore):
        if choices[i] != None:
            if not fp_string_compare(x[col], choices[i], tolerance):
                print >> sys.stderr, x[col], '!=', choices[i]
                return False
    return True
示例#31
0
def chooserListStateCheck(widgetpath, choices, tolerance=None):
    # for ChooserListWidget and friends, including MultiListWidget.
    # Checks that everything in the list 'choices' is selected.
    treeview = gtklogger.findWidget(widgetpath)
    selection = treeview.get_selection()
    model, paths = selection.get_selected_rows()
    if len(paths) != len(choices):
        print >> sys.stderr, "Wrong number of selections:", len(paths), "!=", len(choices)
        return False
    for path in paths:          # loop over actually selected objects
        val = model[path][0]
        for choice in choices:
            if fp_string_compare(val, choice, tolerance):
                break
        else:
            print >> sys.stderr, "Expected:", choices
            print >> sys.stderr, "     Got:", [model[p][0] for p in paths]
            return False
    return True
示例#32
0
文件: generics.py 项目: song2001/OOF2
def chooserListStateCheck(widgetpath, choices, tolerance=None):
    # for ChooserListWidget and friends, including MultiListWidget.
    # Checks that everything in the list 'choices' is selected.
    treeview = gtklogger.findWidget(widgetpath)
    selection = treeview.get_selection()
    model, paths = selection.get_selected_rows()
    if len(paths) != len(choices):
        print >> sys.stderr, "Wrong number of selections:", len(
            paths), "!=", len(choices)
        return False
    for path in paths:  # loop over actually selected objects
        val = model[path][0]
        for choice in choices:
            if fp_string_compare(val, choice, tolerance):
                break
        else:
            print >> sys.stderr, "Expected:", choices
            print >> sys.stderr, "     Got:", [model[p][0] for p in paths]
            return False
    return True
示例#33
0
文件: generics.py 项目: song2001/OOF2
def gtkTextviewGetLines(widgetpath):
    msgbuffer = gtklogger.findWidget(widgetpath).get_buffer()
    text = msgbuffer.get_text(msgbuffer.get_start_iter(),
                              msgbuffer.get_end_iter()).split('\n')
    return text
示例#34
0
def treeViewColValues(widgetpath, col):
    treeview = gtklogger.findWidget(widgetpath)
    liststore = treeview.get_model()
    return [x[col] for  x in iter(liststore)]
示例#35
0
def is_sensitive(widgetpath):
    return _widget_sensitive(gtklogger.findWidget(widgetpath))
示例#36
0
def gtkTextviewGetLines(widgetpath):
    msgbuffer = gtklogger.findWidget(widgetpath).get_buffer()
    text = msgbuffer.get_text(msgbuffer.get_start_iter(),
                              msgbuffer.get_end_iter()).split('\n')
    return text
示例#37
0
def _statusText():
    return gtklogger.findWidget(
        'OOF3D:Skeleton Selection Page:Pane:status').get_text()
示例#38
0
文件: generics.py 项目: song2001/OOF2
def treeViewColValues(widgetpath, col):
    treeview = gtklogger.findWidget(widgetpath)
    liststore = treeview.get_model()
    return [x[col] for x in iter(liststore)]
示例#39
0
文件: generics.py 项目: song2001/OOF2
def is_sensitive(widgetpath):
    return _widget_sensitive(gtklogger.findWidget(widgetpath))
示例#40
0
def _statusText():
    return gtklogger.findWidget(
        'OOF2:Skeleton Selection Page:Pane:status').get_text()
示例#41
0
def treeViewSizeCheck(widgetpath):
    # Returns the contents of the given column of a TreeStore in the
    # selected row of the given TreeView.
    treeview = gtklogger.findWidget(widgetpath)
    selection = treeview.get_selection()
    return selection.count_selected_rows() + 1
示例#42
0
文件: generics.py 项目: song2001/OOF2
def treeViewLength(widgetpath):
    # Return the number of items in the given TreeView.
    treeview = gtklogger.findWidget(widgetpath)
    return len(treeview.get_model())
示例#43
0
def treeViewLength(widgetpath):
    # Return the number of items in the given TreeView.
    treeview = gtklogger.findWidget(widgetpath)
    return len(treeview.get_model())