How to get a list of all config args? - user-interface

How can get a list of all config args?
from tkinter import *
from tkinter import ttk
root=Tk()
root.config(**args)
root.mainloop()
I tried with:
help(root.config)
The output:
Help on method configure in module tkinter:
configure(cnf=None, **kw) method of tkinter.Tk instance
Configure resources of a widget.
The values for resources are specified as keyword
arguments. To get an overview about
the allowed keyword arguments call the method keys.

If by "config args" you mean all the configurable attributes of a particular widget, you can obtain them like this:
my_widget.config()
In other words, what you just need to do is calling the method config (or configure, which is simply an alias) without arguments, which returns a _dictionary with the attributes, their values and more of the widget.
You could also use the pprint function (from the pprint module) to print nicely the attributes, like in the following example:
from tkinter import *
from pprint import pprint
root = Tk()
pprint(root.config())
And the output is the following:
{'background': ('background',
'background',
'Background',
<border object: 'systemWindowBody'>,
'systemWindowBody'),
'bd': ('bd', '-borderwidth'),
'bg': ('bg', '-background'),
'borderwidth': ('borderwidth',
'borderWidth',
'BorderWidth',
<pixel object: '0'>,
0),
'class': ('class', 'class', 'Class', 'Toplevel', 'Tk'),
'colormap': ('colormap', 'colormap', 'Colormap', '', ''),
'container': ('container', 'container', 'Container', 0, 0),
'cursor': ('cursor', 'cursor', 'Cursor', '', ''),
'height': ('height', 'height', 'Height', <pixel object: '0'>, 0),
'highlightbackground': ('highlightbackground',
'highlightBackground',
'HighlightBackground',
<color object: 'systemWindowBody'>,
'systemWindowBody'),
'highlightcolor': ('highlightcolor',
'highlightColor',
'HighlightColor',
<color object: 'Black'>,
'Black'),
'highlightthickness': ('highlightthickness',
'highlightThickness',
'HighlightThickness',
<pixel object: '0'>,
0),
'menu': ('menu', 'menu', 'Menu', '', ''),
'padx': ('padx', 'padX', 'Pad', <pixel object: '0'>, <pixel object: '0'>),
'pady': ('pady', 'padY', 'Pad', <pixel object: '0'>, <pixel object: '0'>),
'relief': ('relief', 'relief', 'Relief', <index object: 'flat'>, 'flat'),
'screen': ('screen', 'screen', 'Screen', '', ''),
'takefocus': ('takefocus', 'takeFocus', 'TakeFocus', '0', '0'),
'use': ('use', 'use', 'Use', '', ''),
'visual': ('visual', 'visual', 'Visual', '', ''),
'width': ('width', 'width', 'Width', <pixel object: '0'>, 0)}
According to the documentation regarding the config method at effbot.org:
config(cnf=None, **kw)
Modifies one or more widget options.
If called without an argument, this method returns a dictionary containing the current settings for all widget options. For each option key in the dictionary, the value is either a five-tuple (option, option database key, option database class, default value, current value), or a two-tuple (option alias, option). The latter case is used for aliases like bg (background) and bd (border width).
Note that the value fields aren’t correctly formatted for some option types. See the description of the keys method for more information, and a workaround.

Thank you #Axl for your answer .
from tkinter import *
from pprint import pprint
root=Tk()
pprint(root.key())
this code also works for me .

Related

Test color with chai-colors plugin

I'm trying to add chai-colors plugin to Cypress, from How to install the plugin "Chai Sorted" #2441
Chris Breiding gives
import chaiSorted from "chai-sorted"
chai.use(chaiSorted)
so for chai-colors
import chaiColors from 'chai-colors'
chai.use(chaiColors)
cy.visit(...)
cy.get(selector)
.should('be.colored', '#000000')
but this gives the error "Timed out retrying after 4000ms: actual.equals is not a function"
To use chai-colors inside a .should() you need to pass in the color code itself (not the element)
import chaiColors from 'chai-colors'
chai.use(chaiColors)
cy.visit(...)
cy.get(selector)
.then($el => $el.css('color')) // get color value
.should('be.colored', '#000000')
But note, this fails
import chaiColors from 'chai-colors'
chai.use(chaiColors)
cy.visit(...)
cy.get(selector)
.then($el => $el.css('backgroundcolor')) // get color value
.should('be.colored', '#000000')
expected #000000 to be the same color as #000000
because $el.css('backgroundcolor') returns rgba() instead of rgb().
You would be better off importing onecolor which chai-colors uses internally.
Then use the converter any way you want (plus documentation is way better).
import color from 'onecolor'
cy.visit(...)
cy.get(selector)
.then($el => $el.css('backgroundcolor')) // get color value
.should(colorValue => {
expect(color(colorValue).hex()).to.eq('#000000')
})

Why doesn't KivyMD's toolbar navigation drawer work with datatables?

This code should produce a window that has a datatable in the main area, and a top navigation bar with a
Navigation menu. It works as intended for a number of other uses. Buttons, text fields, dialogue boxes, etc. have no problem, the navigation menu pops out just as it is supposed to. But the second I add the table widget the toolbar menu no longer functions.
I've tried every combination that I can think of to no avail.
from kivymd.app import MDApp
from kivy.uix.screenmanager import Screen, ScreenManager
from kivy.lang import Builder
from kivymd.uix.datatables import MDDataTable
from kivy.metrics import dp
mgr = """
Screen:
NavigationLayout:
ScreenManager:
id: Landing_Manager
Screen:
BoxLayout:
orientation: 'vertical'
MDToolbar:
title: 'test'
left_action_items: [["menu", lambda x: nav_drawer.set_state("open")]]
elevation:9
ScreenManager:
id: Screen_Manager
NewScreen:
id: New_Screen
name: 'NewScreen'
manager: Screen_Manager
MDNavigationDrawer:
id: nav_drawer
BoxLayout:
orientation: 'vertical'
ScrollView:
MDList:
id: container
OneLineIconListItem:
text: 'Item 1'
on_press:
nav_drawer.set_state("close")
OneLineIconListItem:
text: 'Item 2'
on_press:
nav_drawer.set_state("close")
<NewScreen>
"""
class NewScreen(Screen):
def on_enter(self):
self.rows = 3
self.rowInfo = [('','item 1', 'info 1a', 'info1b'),
('','item 2', 'info 2a', 'info2b'),
('','item 3', 'info 3a', 'info3b')]
self.colHeaders = [('check col',dp(30)),
("data col 1",dp(40)),
("data col 2",dp(50)),
("data col 3", dp(20))]
table = MDDataTable(column_data = self.colHeaders,
check = True,
rows_num = self.rows,
row_data = self.rowInfo)
self.add_widget(table)
class LookBusyApp(MDApp):
def build(self):
self.screen = ScreenManager()
self.app = Builder.load_string(mgr)
self.screen.add_widget(NewScreen(name = 'NewScreen'))
return self.app
if __name__ == "__main__":
app = LookBusyApp()
app.run()
Thanks for any help.
So I tracked down the issue and have a fix. I don't know if it is the best fix but it seems to work.
In kivymd.uix.datatables the MDDataTable class was inheriting from BaseDialog, which didn't seem to like working with the screenmanager, I changed the inheriting to Screen and it works.
original:
from kivymd.uix.dialog import BaseDialog
.
.
.
class MDDataTable(BaseDialog):
updated:
from kivymd.uix.dialog import Screen
.
.
.
class MDDataTable(Screen):
Additionally, from the builder-> MDDataTable ->canvas these 2 lines needs to be removed:
Color:
rgba: root.theme_cls.bg_normal

BG Colour menu does not seem to appear once full toolbar is configured on TestLink 1.9.16

CKeditor version 4.6
Browser : Firefox.54
OS :Linux 3.13.0-36-generic
I tried to configure the cfkeditor within the testlink tool and provided the configurations as below in order to get the full toolbar. However, I cannot seem to get the BGColor menu option.
steps
1.configure the cfg/tl_ckeditor_config.js as shown below 1
2.call the menu name Full within the config.ini.php as below[2]
Note: How can I obtain the BGColor menu button.
1 cfg/tl_ckeditor_config.js
config.toolbar_Full =
[
['Source','-','Save','NewPage','Preview','-','Templates'],
['Cut','Copy','Paste','PasteText','PasteFromWord','-','Print', 'SpellChecker', 'Scayt'],
['Undo','Redo','-','Find','Replace','-','SelectAll','RemoveFormat'],
['Form', 'Checkbox', 'Radio', 'TextField', 'Textarea', 'Select', 'Button', 'ImageButton', 'HiddenField'],
'/',
['Bold','Italic','Underline','Strike','-','Subscript','Superscript'],
['NumberedList','BulletedList','-','Outdent','Indent','Blockquote','CreateDiv'],
['JustifyLeft','JustifyCenter','JustifyRight','JustifyBlock'],
['BidiLtr', 'BidiRtl' ],
['Link','Unlink','Anchor'],
['Image','Flash','Table','HorizontalRule','Smiley','SpecialChar','PageBreak'],
'/',
['Styles','Format','Font','FontSize'],
['TextColor','BGColor'],
['Maximize','ShowBlocks','-','About']
];
[2] config.ini.php
`
$tlCfg->gui->text_editor['steps_design'] = array('type' => 'ckeditor','toolbar' => 'Full',
'configFile' => 'cfg/tl_ckeditor_config.js',
'height' => 50);
$tlCfg->gui->text_editor['execution'] = array( 'type' => 'none');
$tlCfg->gui->text_editor['edit_execution'] = array( 'type' => 'none', 'cols' => 80, 'rows' => 20);
$tlCfg->gui->text_editor['display_execution_notes'] = array('type' => 'none', 'cols' => 80, 'rows' => 20);
`
According to ckeditor's documentation, additional optional plugins are needed to support the BG Color feature.
On the same page, relative to those two items, they also say: (bold emphasis mine)
The Text and Background Color feature does not create semantically
meaningful content. Even if you adjust the color list to match the
style of your website, your users will be able to arbitrarily apply
colors to text elements without any consistency.
A much better idea for creating semantic content and maintaining
consistent styling across your website is to adjust the Styles
drop-down list to include some colors that could be applied to
user-created content and would still be consistent with your website
design.
Probably not what you want to hear, but now you know.

How to replace ttk.Treeview parent node arrow with an image?

Question: How does one create in tkinter.ttk.Treeview a node where the toggling arrow of the node is replaced by a defined image? That is, how do I get from my second picture to the first picture as shown below.
Problem: The New Mexico Tech Guide showed that tkinter.ttk.Treeview can create a folder directory as shown below:
Using the tkinter.ttk.Treeview .insert() method with an "image" keyword, I am only able to achieve the below. An image does appear on the left of the node text, but the image does not replace the arrow toggling the opening and closing of the node to reveal its descendants. I had assumed the image defined by the "image" keyword would replace the toggling arrows. But this did not happen.
Test Code:
import os
import tkinter as tk
import tkinter.ttk as ttk
from PIL import Image, ImageTk
class App(ttk.Frame):
def __init__(self, master, path):
ttk.Frame.__init__(self, master)
self.tree = ttk.Treeview(self)
ysb = ttk.Scrollbar(self, orient='vertical', command=self.tree.yview)
xsb = ttk.Scrollbar(self, orient='horizontal', command=self.tree.xview)
self.tree.configure(yscroll=ysb.set, xscroll=xsb.set)
self.tree.heading('#0', text='Directory', anchor='w')
abspath = os.path.abspath(path)
i = './icon/Home-icon_16.gif'
self.root_pic = tk.PhotoImage(file=i)
root_node = self.tree.insert('', 'end', text=' Work Folder', open=True, image=self.root_pic)
l1_node = self.tree.insert(root_node, 'end', text='level 1', open=True)
l2_node = self.tree.insert(l1_node, 'end', text='level 2', open=True)
l3_node = self.tree.insert(l2_node, 'end', text='level 3', open=True)
l2a_node = self.tree.insert(l1_node, 'end', text='level 2a', open=True)
l3a_node = self.tree.insert(l2a_node, 'end', text='level 3a', open=True)
self.tree.grid(row=0, column=0)
ysb.grid(row=0, column=1, sticky='ns')
xsb.grid(row=1, column=0, sticky='ew')
self.grid()
root = tk.Tk()
path_to_my_project = os.getcwd()
app = App(root, path=path_to_my_project)
app.mainloop()
Home-icon_16.gif:

Dojo: MVC.at does not work in dijit.form.Selects

I am trying to link up the value of a dijit.form.Select to a ListController. I have it working with FilteringSelects and TextBoxes, but it won't work with regular Selects.
I am writing an editor for a list of records. I am using the ListController to represent the list of records, and I want all my widgets to be able to edit the "current record". Each widget, therefore, binds to a different property in the ListController. Then I will be able to switch between the different records, but use the same widgets to edit them.
The controller of course has an idea of which record is the current one, and some of the widgets work. So when I edit, say, the Barcode field with a TextBox widget, the ListController sets the value on the correct record.
However I haven't been able to hook up the Select widget's value to its intended property in the ListController.
I have tried putting the value: mvc.at( controller, 'field' ) in the constructor as well setting it directly after the call, but no dice. Any ideas?
require( [ 'dijit/form/Select', ], function( Select ) {
var testSelect = new Select( {
value: mvc.at( controller, 'field' ), // controller is a ListController
store: store,
searchAttr: "description",
labelAttr: "description"
}, 'TestSelect' );
} );
require( [ 'dijit/form/Select', ], function( Select ) {
var testSelect = new Select( {
store: store,
searchAttr: "description",
labelAttr: "description"
}, 'TestSelect' );
testSelect.set( 'value', mvc.at( controller, 'field' ) );
} );
How does mvc.at() actually work? It doesn't seem to set the value property to an mvc.at value, even on the widgets that do work. There seems to be some winking and nudging going on inside the widget code. Something about _refs?
A dijit/form/Select value is expecting a single value, but a ListController holds an array so you can not directly bind a field in a ListController to a Select's value. You could place the Select inside of a dojox/mvc/Group which has something like this:
data-dojo-props="target: at(controller,'cursor')"
And then you would setup your select with something like this:
value: mvc.at( 'rel:', 'field' ),
And anytime the cursor or cursorIndex is changed on the Controller the select would be updated.
If you want to set the value directly from the controller, I think you would have to do something like this:
value: mvc.at( controller.model[0], 'field' ),

Resources