Skip to content

Commit

Permalink
Fix NoneType error when remembering values between ColumnListArg and …
Browse files Browse the repository at this point in the history
…ColumnArg

#121 (comment)
  • Loading branch information
adamerose committed May 4, 2021
1 parent 7a8ba56 commit ce61322
Showing 1 changed file with 28 additions and 4 deletions.
32 changes: 28 additions & 4 deletions pandasgui/widgets/func_ui.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,8 +394,22 @@ def set_schema(self, schema: Schema):
val = SETTINGS_STORE[arg.arg_name].value
else:
val = arg.default_value
cdz.setText(val)
cdz.valueChanged.emit(val) # Need this incase value was same

# Logic to show value in widget and support converting from ColumnListArg to ColumnArg
if val is None:
val_repr = ''
elif type(val) == str:
val_repr = val
elif type(val) == list:
if len(val) == 0:
val_repr = ''
else:
val_repr = val[0]
else:
raise ValueError

cdz.setText(val_repr)
cdz.valueChanged.emit(val_repr) # Need this incase value was same
cdz.valueChanged.connect(lambda: self.valuesChanged.emit())

elif type(arg) == ColumnListArg:
Expand All @@ -412,8 +426,18 @@ def set_schema(self, schema: Schema):
else:
val = arg.default_value

cldz.set_names(val)
cldz.valueChanged.emit(val) # Need this incase value was same
# Logic to show value in widget and support converting from ColumnArg to ColumnListArg
if val is None:
val_repr = []
elif type(val) == str:
val_repr = [val]
elif type(val) == list:
val_repr = val
else:
raise ValueError

cldz.set_names(val_repr)
cldz.valueChanged.emit(val_repr) # Need this incase value was same
cldz.valueChanged.connect(lambda: self.valuesChanged.emit())

elif type(arg) == BooleanArg:
Expand Down

0 comments on commit ce61322

Please sign in to comment.