我做了我的第一个kivy计划。当我运行这个应用程序时,它会出现空窗口。
这是整个计划。
Python代码:
import java.text.DateFormatSymbols;
import java.util.ArrayList;
import java.util.Calendar;
import java.util.Date;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
public class GroupList {
public static void main(String[] args) {
List<MoveTrack> mveTracking = new ArrayList<>();
mveTracking.add(new MoveTrack(new Date(), 10.0d));
mveTracking.add(new MoveTrack(new Date(), 11.0d));
Map<String, Double> movMap = new HashMap<>();
movMap = mveTracking.stream().collect(Collectors.groupingBy(m -> {
final Calendar cal = Calendar.getInstance();
cal.setTime(m.getTime());
final int month = cal.get(Calendar.MONTH);
return new DateFormatSymbols().getMonths()[month];
}, Collectors.summingDouble(MoveTrack::getMovementAmount)));
System.out.println(movMap);
}
}
final class MoveTrack {
private final Date time;
private final Double movementAmount;
public MoveTrack(final Date time, final Double movementAmount) {
this.time = new Date(time.getTime());
this.movementAmount = movementAmount;
}
public Date getTime() {
return time;
}
public Double getMovementAmount() {
return movementAmount;
}
}
Kivy代码#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
from kivy.app import App
from kivy.uix.boxlayout import BoxLayout
from kivy.properties import ObjectProperty, StringProperty
class Myfirstwidget(BoxLayout):
def text(self, val):
print('text input text is: {txt}'.format(txt=val))
class MainAPP(App):
def build(self):
return Myfirstwidget()
if __name__ == '__main__':
MainAPP().run()
:
myfirstwidget.kv
答案 0 :(得分:2)
将kv文件的名称更改为<?php
$installer = $this;
$installer->startSetup();
// Create the mdg_giftregistry/registry table
$tableName = $installer->getTable('mdg_giftregistry/entity');
// Check if the table already exists
if ($installer->getConnection()->isTableExists($tableName) != true) {
$table = $installer->getConnection()->newTable($tableName)->addColumn('entity_id', Varien_Db_Ddl_Table::TYPE_INTEGER,
null,
array(
'identity' => true,
'unsigned' => true,
'nullable' => false,
'primary' => true,
),
'Entity Id'
)
->addColumn('customer_id', Varien_Db_Ddl_Table::TYPE_INTEGER,
null,
array(
'unsigned' => true,
'nullable' => false,
'default' => '0',
),
'Customer Id'
)
->addColumn('type_id', Varien_Db_Ddl_Table::TYPE_SMALLINT,
null,
array(
'unsigned' => true,
'nullable' => false,
'default' => '0',
),
'Type Id')
->addColumn('website_id', Varien_Db_Ddl_Table::TYPE_SMALLINT,
null,
array(
'unsigned' => true,
'nullable' => false,
'default' => '0',
),
'Website Id'
)
->addColumn('event_name', Varien_Db_Ddl_Table::TYPE_TEXT, 255,
array(),
'Event Name'
)
->addColumn('event_date', Varien_Db_Ddl_Table::TYPE_DATE,
null,
array(),
'Event Date'
)->addColumn('event_country', Varien_Db_Ddl_Table::TYPE_TEXT,
3,
array(),
'Event Country'
)
->addColumn('event_location', Varien_Db_Ddl_Table::TYPE_TEXT,
255,array(),
'Event Location'
)
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
null,
array(
'nullable' => false,
),
'Created At')
->addIndex($installer->getIdxName('mdg_giftregistry/entity',
array('customer_id')),
array('customer_id'))
->addIndex($installer->getIdxName('mdg_giftregistry/entity',
array('website_id')),
array('website_id'))
->addIndex($installer->getIdxName('mdg_giftregistry/entity',
array('type_id')),
array('type_id'))
->addForeignKey(
$installer->getFkName(
'mdg_giftregistry/entity',
'customer_id',
'customer/entity','entity_id'
),
'customer_id', $installer->getTable('customer/entity'),
'entity_id',
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
->addForeignKey(
$installer->getFkName(
'mdg_giftregistry/entity',
'website_id',
'core/website',
'website_id'
),
'website_id', $installer->getTable('core/website'),
'website_id',
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE)
->addForeignKey(
$installer->getFkName('mdg_giftregistry/entity',
'type_id',
'mdg_giftregistry/type',
'type_id'
),
'type_id', $installer->getTable('mdg_giftregistry/type'),
'type_id',
Varien_Db_Ddl_Table::ACTION_CASCADE, Varien_Db_Ddl_Table::ACTION_CASCADE);
$installer->getConnection()->createTable($table);
}
$installer->endSetup();
。
它的名称必须类似于App类的名称,但是小写,没有'app'。更多信息docs。
答案 1 :(得分:0)
问题出在您的kv文件中。
当你这样做时
Button:
on_press: self.text(txt_inpt.text)
您正在按钮,而不是MyFirstWidget实例
相反,你必须这样做:
Button:
on_press:root.text(txt_inpt.text)
那应该有用