如何查询"选择" maya的textScrollList中的项目?

时间:2017-04-03 23:33:24

标签: python user-interface maya

我在maya中使用python,并尝试查询"选择" textScrollList中的项目。在maya的文档中,它展示了如何使用uniqueTag和selectUniqueTagItem,我能够正常工作,但它不是我想要的。

在我的textScrollList中,它附加一个包含列表的变量。当我使用uniqueTag标志时,它会查询"标签"我分配了。我想查询列表中所选项目的内容,而不是标签名称。

例如:

tScrollList = cmds.textScrollList( numberOfRows=8, allowMultiSelection=False,
        append=fileList, showIndexedItem=4, dcc=('doubleClick()') )



def refreshGUI():

    cmds.textScrollList(tScrollList, edit=True, removeAll=True) #removes current list
    newList = searchInput() #this contains a list

    #repopulates list 
    for r in newList:
        cmds.textScrollList(tScrollList, edit=True, append=r, uniqueTag="selectedFile", dcc=('doubleClick()')) 



def doubleClick():

    cmds.textScrollList(tScrollList, edit=True, selectUniqueTagItem=["selectedFile"])

    clickList = cmds.textScrollList(tScrollList, query=True, selectUniqueTagItem= True)   
    print clickList

在双击该项目的gui中,此示例将打印" selectedFile"。我正在尝试打印该列表中的实际所选项目,而不是该标签名称。我似乎无法在谷歌搜索后找到示例,任何帮助/示例将不胜感激!非常感谢。

1 个答案:

答案 0 :(得分:1)

您需要使用选择或双击命令,请检查docs非常清楚。

这是一个有效的最小版本

public class NoticiaFragment extends Fragment {

private RecyclerView recyclerView;
private StaggeredGridLayoutManager mLayoutManager;
private Boolean bool;

private LinearLayoutManager mManager;

FirebaseDatabase database=FirebaseDatabase.getInstance();
DatabaseReference databaseReference=database.getReference();

@Nullable
@Override
 public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container, @Nullable Bundle savedInstanceState) {



    View tab_noticia=inflater.inflate(R.layout.tab_noticias,container,false);
    recyclerView=(RecyclerView)tab_noticia.findViewById(R.id.recyclerNoticias);

    mManager = new LinearLayoutManager(getActivity());



    mManager.setReverseLayout(true);
    mManager.setStackFromEnd(true);

    recyclerView.setLayoutManager(mManager);


    if (recyclerView!=null){
        recyclerView.setHasFixedSize(true);
    }



    final FirebaseRecyclerAdapter<NoticiaModel,NoticiaViewHolder> adapter=new FirebaseRecyclerAdapter
            <NoticiaModel, NoticiaViewHolder>(
            NoticiaModel.class,R.layout.tab_noticias_card,NoticiaViewHolder.class,
           databaseReference.getRef()
                    .child("smiledu")
                    .child("avantgard")
                    .child("noticias")) {
        @Override
        protected void populateViewHolder(NoticiaViewHolder viewHolder, NoticiaModel model, int position) {
            viewHolder.textView.setText(model.getNombre_noticia());

            Picasso.with(getActivity())
                    .load(model.getFoto_noticia())
                    .into(viewHolder.imageView);
            DatabaseReference databaseReference=getRef(position);
            databaseReference.keepSynced(true);
            final String UID=databaseReference.getKey();

            viewHolder.mView.setOnClickListener(new View.OnClickListener() {
                @Override
                public void onClick(View v) {
                    Intent intent=new Intent(getActivity(),NoticiaDetailActivity.class);
                    intent.putExtra("uid",UID);
                    startActivity(intent);
                }
            });

        }
    };

    recyclerView.setAdapter(adapter);
    return tab_noticia;
}
public static class  NoticiaViewHolder extends RecyclerView.ViewHolder{

    View mView;
    ImageView imageView;
    TextView textView;

    public NoticiaViewHolder(View itemView) {
        super(itemView);
        imageView=(ImageView)itemView.findViewById(R.id.noticia_card_image);
        textView=(TextView)itemView.findViewById(R.id.noticia_card_titulo);
        mView=itemView;
    }
 }
}