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

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

Related

How we can use swipe in react navigation V3 with bottomTabNavigator

I'm using react navigation V3 and i want to use swipe in my bottomTabNavigator.
i can't do it because createBottomTabNavigator don't support it any yet and createBottomNavigator is actually deprecated.
It is very annoying because in react navigation V2 we can do iteasily.
Just createMaterialTopTabNavigator support swipe but i want a bottom navigator and not a top one
If you take a look at the documentation for createMaterialTopTabNavigator you can see that in the TabNavigatorConfig there is the ability to set the position of the tab bar using tabBarPosition
Position of the tab bar, can be 'top' or 'bottom', default is top
So if you use createMaterialTopTabNavigator instead of createMaterialBottomTabNavigator and set tabBarPosition: 'bottom' in your config you should get a createMaterialTopTabNavigator but at the bottom.
Here is what it should look like in code
import Screen1 from './Screen1';
import Screen2 from './Screen2';
import { createMaterialTopTabNavigator, createAppContainer } from 'react-navigation';
const screens = {
Screen1: {
screen: Screen1
},
Screen2: {
screen: Screen2
}
}
const config = {
headerMode: 'none',
initialRouteName: 'Screen1',
tabBarPosition: 'bottom' // <- add this line to your config
}
const MainNavigator = createMaterialTopTabNavigator(screens,config);
export default createAppContainer(MainNavigator);
Here is a snack showing it working https://snack.expo.io/#andypandy/materialtopnavigator-at-the-bottom

NativeScript nativescript-drop-down doesn't read list items correctly

NativeScript newbie here. Trying to add a dropdown / combobox style widget. Looks like nativescript-drop-down should be close. The Demo runs fine but the plugin has two problems in our app. First, the selection items show in the picker as [object Object],[object Object], ... instead of: Item 1,Item 2, Item 3, ...
Second, the contents of the scroll wheel shows just one character per "row", so above [object Object] actually shows on spinner as:
[
o
j
e
c
t
O
b
j
e
c
t
]
,
[
o
...
Related, if we store just strings instead of ValueItems into the ValueList, we get similar results, just one character (instead of one item) on each spinner "row."
Key code snippets:
From page layout:
<DropDown row="0" col="2" class="time-button-selected" hint="Time?" items="{{ hourItems }}"></DropDown>
From component typescript:
<deletia...>
#Component({
selector: "Order",
templateUrl: "./order.component.html",
styleUrls: ['./order.component.scss']
})
export class OrderComponent implements OnInit {
<deletia...>
hourItems = new ValueList<string>();
constructor(private platformHelper: PlatformHelperService,
private appStateService: AppStateService) {
<deletia...>
for (let loop = 0; loop < 20; loop++) {
let vi:ValueItem<string> = { value: `I${loop}`, display: `Item ${loop}`};
this.hourItems.push(vi);
}
}
<deletia...>
}
Any recommendations would be greatly appreciated!

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:

Sencha Touch 2: auto center item in list after scrolling

I'm trying to implement a carousel (or tabs with srcoll) in a similar fashion to the http://zite.com/ application. The main goal is to implement autocentered scrolling of closest to the center item after the scroll end.
Do you have any ideas?
Of course, if you want centered a Ext.Carousel into main Ext.Panel write something like this,
new Ext.Panel({
fullscreen: true,
...
layout: {
type: 'vbox',
align: 'center',
pack: 'center'
},
items: [
new Ext.Carousel({
...
})
]
})
and have fun Carousel centered. I hope this helps. :)
Didn't find any other way than calculating the center manually in the scroll end event and scroll to it.

How to get selected text using the Firefox Add-On SDK?

I'm trying to create a Firefox add-on using the online Add-On SDK.
I'm starting with something simple - I want to add a toolbar button that reads the current selected text.
The documentation for the Selection object makes this looks simple enough:
var selection = require("selection");
if (selection.text)
console.log(selection.text);
This doesn't seem to work for me, I just get null.
Here's my complete code:
var selection = require("selection");
require("widget").Widget({
id: "widgetID1",
label: "Test Mozilla Widget",
contentURL: "http://www.mozilla.org/favicon.ico",
onClick: function(event) {
console.log('selection.text = ' + selection.text);
}
});
I've also tried to create the selection object inside the onClick even, with the same effect.
I am able to use the select event to get notified on new selections, so I guess I can use that instead (and keep the value), but I wonder why the above code isn't working... What am I doing wrong?
The selection variable as defined will only have the selected text as long as it is in focus. Clicking on the widget icon takes focus away from the selected text, so it sees no text selected.
Thats why it works when used inside the listener function.
To confirm this, I tried logging its value when a toolbar button is pressed (using the toolbarbutton module), and it works. Pressing a toolbar button (presumably) does not steal focus.
Here's the code, and you can test it online too:
var selection = require("selection");
var tbb = require("toolbarbutton").ToolbarButton({
id: "test",
label: "test",
image: "http://www.mozilla.org/favicon.ico",
onCommand: function(event) {
console.log('selection = ' + JSON.stringify(selection)); // works!
}
});
Here is a solution using the select event:
var selection = require("selection");
var selectedText = '';
function selectionChanged(event){
//todo: check for selection.isContiguous
selectedText = selection.text;
}
selection.on('select', selectionChanged);
require("widget").Widget({
id: "widgetID1",
label: "Test Mozilla Widget",
contentURL: "http://www.mozilla.org/favicon.ico",
onClick: function(event) {
console.log('Selection: ' + selectedText);
}
});

Resources