Пример #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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
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
def treeViewColValues(widgetpath, col):
    treeview = gtklogger.findWidget(widgetpath)
    liststore = treeview.get_model()
    return [x[col] for x in iter(liststore)]
Пример #39
0
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
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())