@@ -338,84 +338,11 @@ def show_grid(data_frame,
338338 DataFrame before being passed in to the QgridWidget constructor as the
339339 ``df`` kwarg.
340340
341- See the ``QgridWidget`` documentation for descriptions of all of
342- the options that can be set via it's constructor.
343-
344341 :rtype: QgridWidget
345342
346- See Also
347- --------
348- QgridWidget : The widget class that is instantiated and returned by this
349- function.
350- """
351-
352- if show_toolbar is None :
353- show_toolbar = defaults .show_toolbar
354- if precision is None :
355- precision = defaults .precision
356- if not isinstance (precision , Integral ):
357- raise TypeError ("precision must be int, not %s" % type (precision ))
358- if column_options is None :
359- column_options = defaults .column_options
360- else :
361- options = defaults .column_options .copy ()
362- options .update (column_options )
363- column_options = options
364- if grid_options is None :
365- grid_options = defaults .grid_options
366- else :
367- options = defaults .grid_options .copy ()
368- options .update (grid_options )
369- grid_options = options
370- if not isinstance (grid_options , dict ):
371- raise TypeError (
372- "grid_options must be dict, not %s" % type (grid_options )
373- )
374-
375- # if a Series is passed in, convert it to a DataFrame
376- if isinstance (data_frame , pd .Series ):
377- data_frame = pd .DataFrame (data_frame )
378- elif not isinstance (data_frame , pd .DataFrame ):
379- raise TypeError (
380- "data_frame must be DataFrame or Series, not %s" % type (data_frame )
381- )
382-
383- column_definitions = (column_definitions or {})
384-
385- # create a visualization for the dataframe
386- return QgridWidget (df = data_frame , precision = precision ,
387- grid_options = grid_options ,
388- column_options = column_options ,
389- column_definitions = column_definitions ,
390- row_edit_callback = row_edit_callback ,
391- show_toolbar = show_toolbar )
392-
393-
394- PAGE_SIZE = 100
395-
396-
397- def stringify (x ):
398- if isinstance (x , string_types ):
399- return x
400- else :
401- return str (x )
402-
403-
404- @widgets .register ()
405- class QgridWidget (widgets .DOMWidget ):
406- """
407- The widget class which is instantiated by the 'show_grid' method, and
408- can also be constructed directly. All of the parameters listed below
409- can be read/updated after instantiation via attributes of the same name
410- as the parameter (since they're implemented as traitlets).
411-
412- When new values are set for any of these options after instantiation
413- (such as df, grid_options, etc), the change takes effect immediately by
414- regenerating the SlickGrid control.
415-
416343 Parameters
417344 ----------
418- df : DataFrame
345+ data_frame : DataFrame
419346 The DataFrame that will be displayed by this instance of
420347 QgridWidget.
421348 grid_options : dict
@@ -528,12 +455,90 @@ class QgridWidget(widgets.DOMWidget):
528455 See Also
529456 --------
530457 set_defaults : Permanently set global defaults for the parameters
531- of the QgridWidget constructor, with the exception of
532- the ``df`` and the ``column_definitions`` parameter.
458+ of ``show_grid``, with the exception of the ``data_frame``
459+ and ``column_definitions`` parameters, since those
460+ depend on the particular set of data being shown by an
461+ instance, and therefore aren't parameters we would want
462+ to set for all QgridWidet instances.
533463 set_grid_option : Permanently set global defaults for individual
534- grid options. Does so by changing the default
535- for the ``grid_options`` parameter of the QgridWidget
536- constructor.
464+ grid options. Does so by changing the defaults
465+ that the ``show_grid`` method uses for the
466+ ``grid_options`` parameter.
467+ QgridWidget : The widget class that is instantiated and returned by this
468+ method.
469+
470+ """
471+
472+ if show_toolbar is None :
473+ show_toolbar = defaults .show_toolbar
474+ if precision is None :
475+ precision = defaults .precision
476+ if not isinstance (precision , Integral ):
477+ raise TypeError ("precision must be int, not %s" % type (precision ))
478+ if column_options is None :
479+ column_options = defaults .column_options
480+ else :
481+ options = defaults .column_options .copy ()
482+ options .update (column_options )
483+ column_options = options
484+ if grid_options is None :
485+ grid_options = defaults .grid_options
486+ else :
487+ options = defaults .grid_options .copy ()
488+ options .update (grid_options )
489+ grid_options = options
490+ if not isinstance (grid_options , dict ):
491+ raise TypeError (
492+ "grid_options must be dict, not %s" % type (grid_options )
493+ )
494+
495+ # if a Series is passed in, convert it to a DataFrame
496+ if isinstance (data_frame , pd .Series ):
497+ data_frame = pd .DataFrame (data_frame )
498+ elif not isinstance (data_frame , pd .DataFrame ):
499+ raise TypeError (
500+ "data_frame must be DataFrame or Series, not %s" % type (data_frame )
501+ )
502+
503+ column_definitions = (column_definitions or {})
504+
505+ # create a visualization for the dataframe
506+ return QgridWidget (df = data_frame , precision = precision ,
507+ grid_options = grid_options ,
508+ column_options = column_options ,
509+ column_definitions = column_definitions ,
510+ row_edit_callback = row_edit_callback ,
511+ show_toolbar = show_toolbar )
512+
513+
514+ PAGE_SIZE = 100
515+
516+
517+ def stringify (x ):
518+ if isinstance (x , string_types ):
519+ return x
520+ else :
521+ return str (x )
522+
523+
524+ @widgets .register ()
525+ class QgridWidget (widgets .DOMWidget ):
526+ """
527+ The widget class which is instantiated by the ``show_grid`` method. This
528+ class can be constructed directly but that's not recommended because
529+ then default options have to be specified explicitly (since default
530+ options are normally provided by the ``show_grid`` method).
531+
532+ The constructor for this class takes all the same parameters as
533+ ``show_grid``, with one exception, which is that the required
534+ ``data_frame`` parameter is replaced by an optional keyword argument
535+ called ``df``.
536+
537+ See Also
538+ --------
539+ show_grid : The method that should be used to construct QgridWidget
540+ instances, because it provides reasonable defaults for all
541+ of the qgrid options.
537542
538543 Attributes
539544 ----------
0 commit comments