小编dds*_*ard的帖子

Python中的Tkinter Entry小部件是不可编辑的

当我运行此代码时,文件选择器出现,然后当我完成它时,我无法输入条目小部件,直到我专注于另一个窗口然后回来.为什么会这样?

import tkinter as tk
from tkinter.filedialog import askopenfilename


location = ''
start = tk.Tk()

tk.Label(text='What is the name of your table?').pack()
box = tk.Entry(start, exportselection=0, state=tk.DISABLED)
box.pack()
button = tk.Button(start, text='OK', command=lambda e: None)
button.pack()
location = askopenfilename(defaultextension='.db', 
                           title="Choose your database", 
                           filetypes=[('Database Files', '.db'), ('All files', '*')])
box.config(state=tk.NORMAL)

start.mainloop()
Run Code Online (Sandbox Code Playgroud)

python filedialog tkinter tkinter-entry

5
推荐指数
1
解决办法
1105
查看次数

如何使用android.support.design.widget.TabLayout创建选项卡的自定义布局?

我找到了以下关于如何设置的文档customView.但是当我将id我的布局更改为"text1"和"icon"时,setText()并且setIcon()不起作用.

public TabLayout.Tab setCustomView(int layoutResId)

设置要用于此选项卡的自定义视图.

如果膨胀的布局包含一个TextViewID为,text1那么将使用给定的值更新setText(CharSequence).同样,如果此布局包含ImageView带有ID的图标,则它将使用给定的值进行更新setIcon(Drawable).

(来源:http://developer.android.com/reference/android/support/design/widget/TabLayout.Tab.html#setCustomView(int))

谁能举个例子说明这是如何运作的?

Java代码:

    TabLayout.Tab tabAdd = tabLayout.getTabAt(0);
    tabAdd.setCustomView(R.layout.tab_layout_custom_view);
    tabAdd.setText("Add");
    tabAdd.setIcon(R.mipmap.add_tab).setText("Add");
Run Code Online (Sandbox Code Playgroud)

布局代码:

<ImageView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="1"
    android:id="@+id/icon"/>
<TextView
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_weight="0"
    android:id="@+id/text1"
    android:gravity="center"
    android:layout_below="@+id/icon" />
Run Code Online (Sandbox Code Playgroud)

android

2
推荐指数
1
解决办法
1094
查看次数

标签 统计

android ×1

filedialog ×1

python ×1

tkinter ×1

tkinter-entry ×1